Browser & Web Performance · Middle · Question 11 of 75

A click handler does heavy, non-urgent work after updating the UI. How can you make the update appear sooner?

button.addEventListener("click", async () => {
  showSpinner();
  // ...heavy work here
});

Explanation

Yielding lets the browser paint the spinner before continuing. Without it, the frame waits for the whole handler.

Further reading

Problem with a question

Browser & Web Performance · Middle · question 11

Test yourself

Take the Browser & Web Performance · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz