🔥 Frontend Interview Cheatsheet That Helped Me Get Offers From Amazon & LinkedIn
If you are preparing for a frontend interview and want to quickly refresh your frontend domain knowledge, this cheatsheet will save you a lot of time.

Content
- 1. Critical Rendering Path
- 2. Reflow
- 3. preload, preconnect, prefetch, prerender
- 4. Rendering Performance
- 5. Workers
- 6. Image Optimization
- 1.
this - 2. Closure
- 3. Inheritance
- 4. Asynchronous Javascript
- 5. Hoisting
- 6. Currying
- 7. Higher-order functions
Intro
Of course, there is not enough space to fit all the frontend knowledge into one article. And this is not what this cheatsheet wants to achieve. This is just a shortcut of frontend topic, that each sr frontend engineer has to be familiar with. They are frequently raised in interviews and helped me to get an offer on Amazon and LinkedIn. Enjoy reading, and feel free to dive deeper by clicking on the topic link 🙌
Web Knowledge
1. Caching
- Cache-Control: instruction of request and response cache;
- Etag: <cache_id>check if the resource was updated by comparing <cache_id>, if not — update the cached version;
2. HTTP/2
Pros:
- Multiple HTTP connection calls (HTTP/1 supports only 6);
- A server can push an event to a client;
- Compress headers;
- More secure
Cons:
- Server push can be abused;
- Can be slower if LB (Load Balancer) supports HTTP/1 and server HTTP/2
3. Security
- Transfer-Encoding — defines how to encrypt body: chunked, gzip;
- Access-Control-Allow-Origin (Cross-Origin Resource Sharing — CORS) Defines a list of domains that can access the API of the origin domain;
- JSONP — run script to access cross-domain data (old browser);
- X-Frame-Options — Prevent clickjacking from iframe;
- Cross-Site Request Forgery (CSRF). Attack: user has a session (logged in), attacker creates link, user clicks on the link and performs the request, attacker steals user session. Prevent: captcha, log out from visited site;
- Content-Security-Policy — prevent from execution harmful code;
- X-XSS-Protection — Enable XSS protection for old sites;
- Feature-Policy — Disable not needed Browser features;
- Referrer-Policy — when there is a link to another website from your site, by clicking it will send the URL of origin which can contain some sensitive data (user id, session);
- Don't allow the user to input any HTML
innerHtml; - Use UI frameworks, keep node_modules updated, and limit of usage 3rd party services;
Web Performance
1. Critical Rendering Path — steps browser makes to paint the page. The steps are:
- DOM — browser compiles the Document Object Model;
- CSSOM — browser compiles the CSS Object Model;
- Render Tree — browser combines DOM and CSSOM to render the tree;
- Layout — browser computes the size and position of each of the objects;
- Paint — browser converts the tree into the pixels in the screen;
Optimize CRP:
- Optimize the order of sources — load critical resources as soon as possible;
- Minimize the number of sources — reduce the number, load async;
2. Reflow —Browser recalculates the position and geometries of the elements after rerender.
Optimize Reflow:
- reduce DOM depths;
- avoid long CSS selectors, minimize rules;
3. preload, preconnect, prefetch, prerender
- preload — loads high prior sources that need to be loaded faster
<link rel="preload">; - preconnect — If some resources are required to accelerate handshake, use
<link rel="preconnect">to reduce latency; - prefetch — loads low prior resources and cache
<link rel="prefetch">; - dns-prefetch—reduce latency of resolving domain names before resources get requested
<link rel="dns-prefetch">; - prerender — similar to prefetch + caches whole the page
<link rel="prerender">;
4. Rendering Performance
JS:
- Move the heavy task to the web worker;
- Use
requestAnimatinFrame instead ofsetTimeoutto perform animation;
Style:
- reduce the complexity of selectors;
- Reduce the number of elements on which style calculation must be applied;
Layout: (how an element is positioned and sized)
Paint: (draw pixels: color, shadows; layout changes trigger repaint)
- Use
will-change to optimize layout repaint;
5. Workers
- Service Worker — interceptor to build an offline app;
- Web Worker — perform heavy tasks on background;
6. Image optimization
Format:
- if animation — use
<video>instead gif - if high details and resolution — PNG
- if geometry shapes — SVG
- if text logo — use font text
- if photo — JPEG
Compression:
- SVG — use optimizer (like SVGO), use gzip;
- WebP — use optimized image format for Web;
- Remove metadata attributes from SVG tag;
- Use Sprites;
Cache and Lazy Load:
- Use CDN for distributing static data;
- Lazy Load images and videos — Use
<img loading="lazy"/>or libraries like lazysizes;
DOM
1. Elements
- selector:
getElementById,getElementByTagName,querySelector,querySelectorAll; - navigation:
children(elements):childNodes(nodes) ,firstElementChild,lastElementChild,parentElement,previousElementSibling,nextElementSibling; - attributes:
classList,clientHeight,clientWidth,childElementCount,setAttribute(attrName, value)removeAttribute(attrName)removeAttribute(attrName);
2. Manipulation
createElement(‘div’), append, prepend, el.cloneNode(true), remove(), insertBefore(newNode, beforeNode), insertAfter(newNode, afterNode);
3. Document Fragment — creates a virtual copy of a document, that can store multiple elements. By inserting document fragment into DOM, it becomes empty, and cause only one reflow;
4. Event delegation and bubbling
- When we emit an Event, ex.
click, the event is bubbling up to<html>element through theparentElementlink:
-html (bubble click)
-body (bubble click)
-div (bubble click)
-p
-p (click)- Delegation is used to improve performance. Let’s say we have a structure:
-div.parent
-p.child
-p.child
-p.childAnd we want to assign an addEventListener to .child , in this case, we have to attach an event to 3 elements. Instead, we can attach events only to .parent and resolve the logic.
document.querySelector(".parent").addEventListener("click", function(event) {
if (event.target.classList.contains("child")) {
// you logic is here
};
});HTML
1. Semantic Elements — clearly describes its meaning with its name to developer and browser: <article>, <aside>, <details>, <figcaption>, <figure>, <footer>, <header>, <main>, <mark>, <nav>, <section>, <summary>, <time> ;
2. Accessibility
- Use headers
<h1>,<h2>,<h3>…; - Use
<img alt=””; - Use attribute
tabindex=”index_position”to navigate the focus usingTabkey; - Use
roleslike<ul role=”list”><li role=”listitem”>,<dialog role=”dialog”. Find the whole list here; - Use
accesskey=”key”for creating keyboard shortcuts; - use attributes to describe the element:
aria-label=”label_text”oraria-labelledby=”text_id”,aria-describedby=”text_id”and<label id="text_id">label_text</label>; - Use color contrasts, textures;
- Use text size;
- Use captions in a video;
3. Responsive web
- Add
<meta viewport name=”viewport” content=”width=device-width, initial-scale=1.0"to give browser direction to scale; - Use
<img max-width=”100%”and the image will not scale more than its size; - Use
<picture> <source srcset=”” media=”” >to specify images for different screen sizes; - Responsive font sizes:
emandrem; - Use media queries;






