JavaScript Browser Rendering Pipeline Quiz

JavaScript
0 Passed
0% acceptance

Test your understanding of how browsers render web pages with 35 questions covering HTML/CSS/JS parsing, the Critical Rendering Path, layout, painting, compositing, and performance optimizations.

35 Questions
~70 minutes
1

Question 1

What is the output of the HTML parser?

A
DOM tree
B
CSSOM tree
C
Render tree
D
Pixel buffer
2

Question 2

What happens when the HTML parser encounters a <script> tag without async or defer?

A
Parsing blocks until the script is downloaded and executed
B
Script execution is deferred to after page load
C
The script runs in a separate thread
D
Parsing continues while the script loads
3

Question 3

What does the CSS parser produce?

A
CSSOM tree
B
DOM tree
C
JavaScript AST
D
Layer tree
4

Question 4

Why can external stylesheets block rendering?

A
Because the render tree requires both DOM and CSSOM, and CSS is render-blocking
B
Because CSS runs on the main thread only
C
Because browsers ignore HTML until CSS loads
D
Because CSS must be minified first
5

Question 5

What does this script placement typically cause?

xml
<head>
  <script src="app.js"></script>
</head>
A
Delayed DOM construction until app.js loads and executes
B
Faster rendering due to early script execution
C
Parallel parsing of HTML and JS
D
Automatic deferral of script execution
6

Question 6

What is the Critical Rendering Path?

A
The sequence of steps required to render the initial view of a web page
B
The path JavaScript takes through the event loop
C
The CSS cascade order
D
The route of HTTP requests
7

Question 7

Which resource is NOT render-blocking by default?

A
JavaScript with async attribute
B
External CSS
C
Synchronous JavaScript
D
Inline CSS
8

Question 8

What is the purpose of the render tree?

A
To combine visible DOM nodes with computed styles for layout
B
To store all CSS rules
C
To execute JavaScript
D
To manage network requests
9

Question 9

Which of the following helps optimize the Critical Rendering Path?

A
Inlining critical CSS and deferring non-critical JavaScript
B
Loading all scripts in the <head>
C
Using large external stylesheets
D
Avoiding the DOMContentLoaded event
10

Question 10

What does First Contentful Paint (FCP) measure?

A
Time from navigation to when the first text or image is painted
B
Time to execute all JavaScript
C
Time to download all assets
D
Time until user interaction is possible
11

Question 11

How does JavaScript execution affect rendering?

A
Long-running JS can block the main thread, delaying layout and paint
B
JavaScript runs after all rendering is complete
C
It has no impact on rendering
D
It forces immediate compositing
12

Question 12

When is the DOMContentLoaded event fired?

A
After HTML is parsed and DOM is ready, but before external resources like images load
B
After all images and stylesheets load
C
Before HTML parsing begins
D
Only after all scripts execute
13

Question 13

What does requestAnimationFrame() do in relation to rendering?

A
Schedules a function to run before the next repaint
B
Forces immediate layout
C
Pauses JavaScript execution
D
Skips the paint phase
14

Question 14

What happens if you read layout properties (e.g., offsetHeight) right after a DOM mutation?

javascript
element.style.width = '200px';
console.log(element.offsetWidth);
A
It triggers a forced synchronous layout (layout thrashing)
B
It returns cached layout data
C
It defers layout to next frame
D
It throws an error
15

Question 15

Which task runs in the same event loop phase as rendering?

A
Microtasks (e.g., Promise callbacks)
B
setTimeout callbacks
C
Network callbacks
D
requestIdleCallback tasks
16

Question 16

What is layout (reflow)?

A
The process of computing the exact position and size of every visible element
B
The process of drawing pixels
C
The parsing of CSS selectors
D
The creation of the DOM
17

Question 17

Which CSS property change typically triggers layout?

A
width
B
background-color
C
opacity
D
transform
18

Question 18

What is the cost of layout relative to other rendering steps?

A
Generally more expensive than paint or compositing
B
Cheaper than JavaScript execution
C
Free if cached
D
Always runs on GPU
19

Question 19

How can you avoid “layout thrashing” in a loop?

javascript
for (let i = 0; i < 100; i++) {
  element.style.height = i + 'px';
  console.log(element.clientHeight); // BAD: forces layout each iteration
}
A
Batch all writes first, then do reads
B
Use setTimeout between iterations
C
Avoid loops entirely
D
Call disconnect() on the element
20

Question 20

Does changing an element’s color trigger layout?

A
No, it only triggers paint
B
Yes, always
C
Only if the element is positioned
D
Only in Firefox
21

Question 21

What is painting in the rendering pipeline?

A
Filling pixels based on computed styles (e.g., text, colors, shadows)
B
Computing element positions
C
Downloading images
D
Executing JavaScript
22

Question 22

What enables compositing in modern browsers?

A
Promoting elements to their own layers
B
Using only inline styles
C
Avoiding CSS entirely
D
Disabling JavaScript
23

Question 23

Which CSS property commonly promotes an element to its own compositing layer?

A
will-change: transform
B
display: block
C
position: static
D
color: red
24

Question 24

What happens during the compositing stage?

A
The browser combines painted layers into a final image for the screen
B
JavaScript is executed
C
HTML is reparsed
D
Network requests are prioritized
25

Question 25

Why is transform: translateX() preferred over left for animations?

A
It can be handled by the compositor without layout or paint
B
It uses less memory
C
It works only on block elements
D
It triggers synchronous layout
26

Question 26

What is a key benefit of using passive event listeners?

A
They improve scroll performance by not blocking the main thread
B
They prevent all JavaScript execution
C
They disable layout
D
They reduce HTML size
27

Question 27

Which technique reduces layout impact when animating many elements?

A
Animate only transform and opacity
B
Use setInterval for timing
C
Change width and height frequently
D
Avoid CSS entirely
28

Question 28

What does this code risk?

javascript
function updateElements() {
  for (let el of document.querySelectorAll('.item')) {
    el.style.top = el.offsetTop + 10 + 'px';
  }
}
A
Forced synchronous layout in a loop (layout thrashing)
B
Memory leak
C
Cross-origin error
D
Infinite recursion
29

Question 29

How can you minimize the impact of DOM mutations on performance?

A
Batch changes using DocumentFragment or hidden container
B
Mutate one element at a time
C
Use innerHTML exclusively
D
Avoid the DOM entirely
30

Question 30

What is the purpose of the contain CSS property?

A
To isolate an element’s subtree for performance (layout, paint, or size)
B
To hide content from screen readers
C
To compress CSS files
D
To prevent JavaScript execution
31

Question 31

What logs after this sequence?

javascript
const el = document.getElementById('box');
el.style.width = '100px';
el.style.height = '100px';
// Assume no layout triggered yet
console.log('done');
A
'done'
B
An error
C
undefined
D
100
32

Question 32

Which tool helps visualize the rendering pipeline in DevTools?

A
Performance tab
B
Console tab
C
Elements tab only
D
Network tab
33

Question 33

What is “jank” in rendering?

A
Visible stuttering due to missed frame deadlines (e.g., >16ms per frame)
B
A type of memory leak
C
A CSS parsing error
D
An HTTP timeout
34

Question 34

What does this CSS do for performance?

css
.animated {
  will-change: transform;
}
A
Hints to the browser to prepare a compositing layer for transform animations
B
Disables JavaScript
C
Forces layout on every frame
D
Reduces image quality
35

Question 35

Why should you avoid querying element dimensions inside a loop?

javascript
for (let i = 0; i < items.length; i++) {
  items[i].style.width = container.clientWidth + 'px';
}
A
It may cause repeated forced layouts if styles changed before the loop
B
It always throws an error
C
It runs on a separate thread
D
It disables compositing

QUIZZES IN JavaScript