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 adding the data-cfasync attribute to injected Javascripts (e.g. those not present in the HTML returned by the origin) will not allow RocketLoader to include or exclude these scripts in Manual or Automatic mode.

If you send a CSP (content security policy) header, you will need to modify it to allow RocketLoader to run. RocketLoader is hosted on ajax.cloudflare.com, so you'll need to add ajax.cloudflare.com to the list of allowed domains for scripts  

An example CSP header value compatible with RocketLoader would be:

script-src 'unsafe-eval' 'self' ajax.cloudflare.com;
Still not finding what you need?

The Cloudflare team is here to help. 95% of questions can be answered using the search tool, but if you can’t find what you need, submit a support request.

Powered by Zendesk