Web Performance 101: Critical Render Path
In this web performance 101 article, we explore critical render path and its role in the functioning and performance of your website. Learn more here.
The 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 webpage, the better the digital experience. We’ve already discussed how page size, images, and scripts can affect webpage 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.
Tech Terms ExplainedDOMDocument object model defines the structure of the webpage, the HTML elements are rendered on the page based on the DOM.CSSOMCSS is parsed to form the CSS object model which defines the style rules for the webpage.Render StartThe time taken to receive the first byte of data for the primary URL.
A browser needs to construct the structure of the page before rendering. The webpage 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/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 is 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 webpage.
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 which 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 US 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 will 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 will reduce browser overhead and help speed up the render process.
- By optimizing the order in which each critical resource is downloaded or lazy-loading assets that are not critical, we can 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 webpage 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.