With this release, we’ve vastly improved and streamlined Rocket Loader so that it works in conjunction with mobile & desktop browsers to prioritise what matters most when loading a webpage: your content.
Visitors don’t wait for page “load”
To put it very simplistically – load time is a measure of when the browser has finished loading the document (HTML) and all assets referenced by that document.
When you clicked to visit this blog post, did you wait for the spinning wheel on your browser tab to start reading this content? You probably didn’t, and neither do your visitors. We’re conditioned to start consuming content as soon as it appears. However the industry had been focused on the load event timing too much, ignoring user perception & behaviour. Data from Google analytics has shown that 53% of visits are abandoned if a mobile site takes longer than 3 seconds to load. This makes sense if you think about the last time you browser onto a website in a hurry – if nothing is rendered quickly on screen you’re much more likely to go elsewhere.
Paint timing metrics are a closer approximation of how your users perceive speed. Put simply, paint timing measures when something is displayed on screen, and there are various stages of paint that can be measured & reported which we’ll explain as we go.
Analysing your performance
One of the ways in which you can learn more about your website’s performance is to use one of the many great synthetic analysis tools out there. The Lighthouse tool in Chrome can run a performance audit on your page simulating a typical mobile device & connection. I ran this on Cloudflare’s homepage to illustrate the way the page loads over time:
The First Meaningful Paint (FMP) takes 4.8 seconds on this mobile device simulation. FMP doesn’t measure the time of the first paint, but it waits for any web fonts to render and for the biggest above-the-fold layout change to happen. The red line drawn at 4.8 seconds shows our FMP in this test. So what can we do to improve?
Render blocking scripts are a problem for paint times
Most tools will give you suggestions, and Lighthouse calls these opportunities and orders these by their estimated time saving:
Try running a lighthouse audit on your website and see what opportunities you get.
The march of the scripts
Implementing this recommendation would require you to make changes to your origin application’s code to asynchronously load, defer or inline your scripts. In some cases this might not be possible because you don’t control your application’s code or have the expertise to implement these strategies. Rocket Loader to the rescue!
How Rocket Loader works
|Without Rocket Loader||With Rocket Loader|
Enabling Rocket Loader
This bit is quite labour-intensive, so watch closely:
Measuring the impact
Let’s run lighthouse again on our homepage now we have Rocket Loader enabled:
So Lighthouse has detected that First Meaningful Paint is just over 1.5 seconds faster in this test – a really impressive improvement delivered from a single click!
To drive this home, the opportunity lighthouse identified is now officially a “passed audit”:
Let’s get Real (User Measurement)
To illustrate the changes we observed, below is a graph of the Time To First Contentful Paint (TTCP) for www.cloudflare.com visits by real users during our test. TTFCP measures the first time something in the Document Object Model (DOM) is painted on the page. For websites that are primarily for consumption of content rather than heavy interactions, this is a closer representation of a user’s perception of your website speed than measuring load time.
With Rocket Loader you can see those orange bars are grouped more to the left (faster) and higher meaning many more of our visitors were getting content on screen in under a second. In fact, the median improvement delivered by Rocket Loader during our www.cloudflare.com test lands at a 0.93 second reduction in Time To First Contentful paint or around a 45% improvement over the baseline. Boom!
What’s new in Rocket Loader
- Improves time to first paint speed not just load time
- Now compatible with over 93% of mobile devices
- Tiny! Less than 10% of the size of prior version
- Compliant with stricter Content Security Policies (CSP)
More mobile users now get optimised
We’ve already predicted that by the end of 2018 mobile usage will reach 60%. Additionally as of July 2018 Google will begin using page speed in mobile search ranking. With that in mind providing a fast experience for mobile devices is more important than ever.
Leaner & Meaner
New Rocket Loader’s JS weighs in at a lightweight 2.3KB. We did some extensive refactoring during 2017 that reduced the size of the JS required to run Rocket Loader from 47KB to 32KB and saved a staggering 213 terabytes of transfer across the globe. Due to the simplicity of the way New Rocket Loader works rocket-loader.min.js resulting in a JS file that is less than 10% of the size, saving approximately another 417 Terabytes of transfer each year when Rocket Loader does its thing.
Compatibility with Content Security Policy
https://ajax.cloudflare.com so that Rocket Loader itself can load.
How can I enable new Rocket Loader?
If you already have Rocket Loader enabled as of today your site is using the new version. You can modify your settings at any time by visiting the Speed section of your settings.
If you had Rocket Loader disabled or in Manual mode just click the button in the Speed section to turn Rocket Loader on.
What else can I do with Cloudflare to optimise my website?
- Caching – cache everything you can so content is served directly from any one of our 150+ data centres without waiting for your origin.
- Minify & Compress – Enable minification of your HTML, CSS & JS in your Speed settings to losslessly reduce the total byte size of your web pages and enable Brotli compression so browsers that support this new compression method receive smaller responses.
- Optimise your images – Polish will automatically reduce the size of images on your website with support for highly efficient formats such as WebP. You can also turn on Mirage to optimise images for mobile devices with poor connectivity.
- Use HTTP/2 – You get HTTP/2 support automatically as long as your site is served over HTTPS. Move as much as your content as you can onto your Cloudflare enabled URLs so all of that content can be multiplexed down a single TCP connection.
- Use Argo & Railgun – For dynamic content Argo and Railgun can help optimise the connection & transfer between Cloudflare and your origin server.
Back of the envelope calculations based on 270 million rocket-loader.min.js responses served per week with a 29.7KB saving per serving. ↩︎