← All videos

Engineering video

8:40 · 6 May 2024

Frontend Interview Questions 2025 (Part 3)

Chapters 5 sections

  1. 0:00Critical CSS
  2. 2:00Defer and Async Script Attributes
  3. 4:00ES6 Dynamic Imports
  4. 5:18Cumulative Layout Shift (CLS)

Key concepts in this video:

1. Critical CSS Extraction and Purpose

Critical CSS encompasses styles needed for above-the-fold elements, which can be extracted using tools like Webpack plugins and Puppeteer to improve performance by deferring non-essential styles.

Watch section from 0:00 →

2. ARIA Attributes for Accessibility

ARIA attributes specify semantic accessibility roles for non-semantic HTML elements (like divs or spans) when design constraints prevent the use of proper semantic HTML.

Watch section from 0:00 →

3. Script Loading with Defer and Async

Defer downloads scripts in parallel during HTML rendering and executes them before DOMContentLoaded, whereas async downloads and executes scripts as soon as possible without waiting for HTML rendering.

Watch section from 2:00 →

4. Static Versus Dynamic Imports in ES6

Normal static imports happen at build time, enabling tree shaking and TypeScript type inference, while dynamic imports function like network-fetching promises that can be evaluated conditionally at runtime for lazy loading.

Watch section from 4:03 →

5. Cumulative Layout Shift (CLS) and Mitigation

CLS measures unexpected layout shifts during page load caused by late-arriving assets like images, fonts, or styles, which can be mitigated using fixed dimensions and debugging performance tools.

Watch section from 5:21 →

6. Essential Versus Derived State

Essential state changes independently and stems from user interactions or network data, whereas derived state is calculated or computed directly from existing essential state variables.

Watch section from 7:05 →

Transcript

Hi folks. Here we go. Senior front end interview questions. Now, Bug, are you ready? Yes, let's go. Very important question comes up uh every almost in every front end engineering interview I've been doing. What is critical CSS? And how do we extract it in a on a web page? Ah, sure. So, critical CSS is the name we give to the CSS styles needed to display the elements uh that appear above the fold. So, basically imagine you land on a page and you see certain elements without scrolling. That would be uh the above the fold elements in the critical CSS. It's all the CSS we need in order to make those elements uh position and to style them. In order to extract it, uh you can use certain module bundle plugins, like I used in the past, the Webpack plugin. It will basically render the application with Puppeteer, a headless browser. So, in the background, it will render the application for the specific width, and then it will use browser mechanism like the CSS coverage to extract the CSS tiles that you need to render a specific width. Once you extracted critical CSS, you can use it to improve the performance of your application by deferring all the CSS except the critical CSS. Because CSS it's a unique name space, browser really try to collect all the CSS in uh in it and render it before they move on with the HTML part. So, if we have a lot of CSS that uh that can take a long a very long time and decrease the application speed. So, if we are able to separate that, we can improve uh drastically the the performance. Cool. Now we're going to move on with a accessibility question. Have you ever heard about the area attributes in HTML and when are they useful? So, most of the times we just want to stick to semantic HTML. That's the easiest and best way to make something accessible. But there is some edge cases where we just cannot use