What does Rocket Loader do? - monlife

Hot

Post Top Ad

Monday 23 October 2017

What does Rocket Loader do?


Rocket Loader is a general-purpose asynchronous JavaScript loader coupled with a lightweight virtual browser which can safely run any JavaScript code after window.onload. 

Turning on Rocket Loader will almost always immediately improve a web page's window.onload time (assuming there is JavaScript on the page).

Here are the different settings that can be found for Rocket Loader under your Cloudflare account's performance settings:
Automatic Mode: Rocket Loader will automatically run on the JavaScript resources on your site, with no configuration required after turning on automatic mode.
Manual Mode: In order to have Rocket Loader execute for a particular script, you must add the following attribute to the script tag: "data-cfasync='true'". As your page passes through Cloudflare, we'll enable Rocket Loader for that particular script. All other JavaScript will continue to execute without Cloudflare touching the script.

Please note that: 

1. Adding the 'data-cfasync' attribute within JS will not work to exclude the script from Rocket Loader.
2. The 'data-cfasync' attribute must be added before the 'src' attribute. 
3. Rocket loader will recognize the tag when either single or double quotes are placed around the attribute value. 

No comments:

Post a Comment

Post Top Ad