⚠️ This lesson is retired and might contain outdated information.

See the Critical Rendering Path in the browser

Yonatan Kra
InstructorYonatan Kra
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 2 years ago

The Critical Rendering Path is what happens from the moment your javascript is running to the moment something changes on screen. In this lesson, we will see how to monitor and view the critical rendering path in the browser.

Instructor: [00:00] The critical rendering path is the flow of what happens from the moment your JavaScript is running until the moment something changes on screen. The flow works like this.

[00:12] Your JavaScript is running. When it's done, style calculations are being made, then layout calculations, then paint, and eventually, it comes to composite.

[00:30] Now, we'll explain each part. JavaScript doesn't really need much explanation. Style calculation goes over your CSS properties or definitions and applies them to the page.

[00:43] Layout calculates the dimensions and positions of elements in the page. Paint puts the pixels on screen and composite handles complex stuff like z-indexing. If you have elements that are above or below each other, that's where this calculation is being made.

[01:08] How do we see this flow in the browser? Look at this application. This application is a very simple one. What it does, it shows us a button on screen. This bottom when it's clicked, it calls for an add item function that creates a new element of type Dev, set it's in inner text to high and appends it to our operative.

[01:31] If we click here, we'll see the high being added to the screen. Let's see the critical rendering path in this simple case. We go into the performance tool of Chrome DevTools. Click F12 then go to the performance tab, and let's start recording. We start recording. We'll click our item a few times, and then we'll stop.

[01:56] We'll go to full screen, we'll look for it. Let's hit Ctrl+F and look for our function add item. We'll find it here. Let's look for it here and there it is. We'll zoom in to where the function is and then we'll see the critical rendering path. We have the yellow part which is JavaScript.

[02:20] Here is the JavaScript and here's our function. It's all in the yellow part. After the JavaScript finishes, it calculates styles. Then we have the layout calculations. If we go a bit to the right, we have the update layer tree, which follows the layout calculation, in this case, then the paint, and then the composite layers. This is how you see the critical rendering path in the browser.

egghead
egghead
~ 41 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today