Web Performance 101: Critical Render Path
To optimize the critical render path for your web page, you must analyze the assets that are critical to the initial view.
Join the DZone community and get the full member experience.
Join For Freethe success of a website is directly proportional to the users’ digital experience. in the age of tech, savvy consumers, and competitive targeted marketing, speed matters. users expect websites to load fast. the faster the user can view the web page, the better the digital experience. we’ve already discussed how page size , images , and scripts can affect web page load time and how each of these factors can be optimized to deliver the best user experience. in this article, we look at another important factor that determines web performance: critical render path.
what is critical render path?
the series of events involved in downloading website resources (html, css, and scripts), processing, and rendering the first pixel on the page is called the critical render path.
a browser needs to construct the structure of the page before rendering. the web page data structure has two main components: dom (document object model) and cssom (css object model). the browser parses the page html to form the dom while the css is used to build the cssom.
the html is received by the browser in raw bytes, which is converted to characters. the html markup tokens and tags (for example: “<head>”, “<body>”) are then generated. these tags are then mapped to form nodes that make up the dom tree.
a similar process is carried out by the browser when it receives the css rules. the data is converted to characters and tokens, which are then linked to form the cssom tree.
the dom and the cssom together form the final render tree. the browser paints each node on the page following the render tree path. the entire process takes time and can impact the overall performance of the web page.
how significant is the critical render path?
the initial view of the page, or what the user views above the fold, is critical to the end-user experience. optimizing each step in the critical render path will speed up the rendering process of above-the-fold content, resulting in a better digital experience.
if the page html contains any render-blocking script or css, then the render start will be delayed. most websites are cluttered with multiple css files, scripts, and images that are not critical for rendering the first pixel. a user is more likely to wait for a page to load if an initial layout is displayed versus a blank page.
we can see this in action in the image below. the filmstrip shows the number of seconds the page remains blank before the first pixel is displayed. amazon paints the first pixel within a second while nordstrom takes 2.4 seconds.
the time taken by the initial render sets the tone for the users’ digital experience. the user perceives a better web performance even if the rest of the page takes another second to fully load.
let us compare the critical render path from another perspective. the following waterfall graphs give us a better understanding of the page design and critical render path. the graph below for axis bank shows several scripts and other resources being loaded before the page starts to render. this can be detrimental to the end-users’ digital experience.
in contrast, the waterfall chart for u.s. bank gives an example of an optimized render path. there are fewer resources that need to be downloaded before the initial render.
what is the ideal render path?
to optimize the critical render path, we must focus on the following three factors.
- reducing the number of critical assets to allow the browser to start rendering the initial view/above-the-fold content quickly without waiting for the rest of the resources to complete loading.
- minimizing the byte size of the critical resources to reduce browser overhead and help speed up the rendering process.
- optimizing the order in which each critical resource is downloaded or lazy-loading assets that are not critical to minimize the round trips the browser needs to make to fetch each critical resource and in effect reduce the length of the critical render path.
to build the ideal render path for your web page, you must analyze the assets that are critical to the initial view. the resources must then be minimized and optimized to reduce the overhead on the browser. this will ensure the progressive rendering of the page begins as fast as possible. the page will continue to load and draw all the other elements but this will not disrupt what the user views above the fold.
Published at DZone with permission of Kameerath Abdul Kareem, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments