Skip to content
FrontDepth, Home

Back to the topic

Practice: Critical Rendering Path

Answer first, then compare. Rate yourself honestly — it drives your weak-areas list.

3 predict-output · 4 open

Questions up to level

Shows questions up to the selected level.

No practice questions for this level yet.

  1. Predict the outputJunior

    This script runs inline at the end of the body of an otherwise empty page. What does it log?

    JavaScript
    const box = document.createElement("div");
    box.style.width = "100px";
    document.body.appendChild(box);
    console.log(box.offsetWidth);
    
    box.style.display = "none";
    console.log(box.offsetWidth);
    console.log(getComputedStyle(box).width);
    
    box.style.display = "block";
    box.style.visibility = "hidden";
    console.log(box.offsetWidth);
  2. Open questionJunior

    What happens between the browser receiving HTML and the first pixels appearing on the screen?

    Think it through first

    Answer out loud or in your head as if you were in an interview, then reveal.

  3. Predict the outputMiddle

    This script runs inline in the head of a normally loaded page with an empty body. What does it log?

    JavaScript
    document.addEventListener("DOMContentLoaded", () => {
      console.log("DOMContentLoaded");
      console.log(document.readyState);
    });
    window.addEventListener("load", () => {
      console.log("load");
      console.log(document.readyState);
    });
    queueMicrotask(() => {
      console.log("microtask");
      console.log(document.readyState);
    });
    console.log(document.readyState);
    console.log(document.body === null);
  4. Open questionMiddle

    What is the difference between a regular <script>, async and defer? When would you use each?

    Think it through first

    Answer out loud or in your head as if you were in an interview, then reveal.

  5. Open questionMiddle

    What is layout thrashing and how do you avoid it?

    Think it through first

    Answer out loud or in your head as if you were in an interview, then reveal.

  6. Predict the outputSenior

    This script runs inline at the end of the body of an otherwise empty page. What does it log?

    JavaScript
    const box = document.createElement("div");
    box.style.width = "100px";
    document.body.appendChild(box);
    
    box.style.transform = "scale(2)";
    console.log(box.offsetWidth);
    console.log(box.getBoundingClientRect().width);
    
    box.style.width = "150px";
    console.log(box.offsetWidth);
    console.log(box.getBoundingClientRect().width);
  7. Open questionSenior

    A client-rendered React app has a slow LCP. How would you diagnose and improve it?

    Think it through first

    Answer out loud or in your head as if you were in an interview, then reveal.