π₯ Frontend Interview Cheatsheet That Helped Me Get Offers From companies like Amazon & LinkedIn
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 π
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
- Multiple HTTP connection calls (HTTP/1 supports only 6);
- A server can push an event to a client;
- Compress headers;
- More secure
- Server push can be abused;
- Can be slower if LB (Load Balancer) supports HTTP/1 and server HTTP/2
- 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;
- 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;
- 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">
;
JS
- Move the heavy task to the web worker;
- Use requestAnimatinFrame instead of setTimeoutto 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;
- Service Worker β interceptor to build an offline app;
- Web Worker β perform heavy tasks on background;
Format:
- if animation β use
- 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 dataLazy Load images and videos β Use or libraries like lazysizes;
- Elements
- Manipulation
- Document Fragment
- Event delegation and bubbling
- Semantic Elements
- Accessibility
- Responsive web Javascript 1.this
- Closure
- Inheritance
- Asynchronous Javascript
- Hoisting
- Currying
- Higher-order functions
- Mixin
- Factory
- Singleton
- Facade
- MVC, MVVM
- Server vs Client-Side Rendering
Conclusion
You are Awesome β€οΈ
Learn More - https://itnext.io/frontend-interview-cheatsheet-that-helped-me-to-get-offer-on-amazon-and-linkedin-cba9584e33c7