General

Prevent CloudFlare from Loading a js or Script

Updated November 2026 7,054 views 3 min read
General | Updated November 2026

Cloudflare's Rocket Loader speeds up pages by deferring and asynchronously loading JavaScript, but it can break sliders, forms, interactive widgets, and third-party scripts that expect to run in order. You can turn Rocket Loader off entirely, or keep it on and exclude just the scripts it breaks with a data-cfasync attribute. A few other Cloudflare optimizations can affect scripts too.

Fix

Disable Rocket Loader, or exclude the one script it breaks

In the Cloudflare dashboard go to Speed then Optimization then Content Optimization and toggle Rocket Loader off. To keep it on but skip a specific script, add data-cfasync="false" to that script tag.

01. What Rocket Loader Does

Rocket Loader delays JavaScript until after the page renders and loads it asynchronously, which improves the first paint on script-heavy pages. The trade-off is timing: scripts that expect to run immediately, or in a specific order, can break. Common symptoms are a slider or carousel that does not start, a form or date-picker that does not respond, or a third-party embed that fails to initialize.

02. Disable Rocket Loader

The quickest fix is to turn it off:

  1. Log into the Cloudflare dashboard and select your domain.
  2. Go to Speed then Optimization then Content Optimization.
  3. Toggle Rocket Loader to Off.
  4. Purge the Cloudflare cache and hard-refresh your site to confirm the scripts work.

Turning Rocket Loader off does not affect Cloudflare's caching, CDN, or SSL, which are independent features.

03. Exclude a Specific Script

If Rocket Loader helps performance and only one script breaks, keep it on and exclude that script by adding data-cfasync="false" to the tag:

<script data-cfasync="false" src="/js/critical-script.js"></script>

The attribute tells Cloudflare to leave that script alone while still optimizing the rest. Add it to the specific script that misbehaves, for example your slider or form library. In WordPress, you can add the attribute via your theme or a small functions.php filter on the script tag.

04. Other Cloudflare Features That Break JS

If a script still misbehaves with Rocket Loader off, check these Cloudflare optimizations:

  • Auto Minify - minifying JavaScript can break poorly-formatted scripts. Cloudflare has retired Auto Minify for most accounts, but if yours still has it, try disabling JS minification.
  • Mirage and Polish - these optimize images and rarely affect JS, but rule them out if image-dependent scripts fail.
  • Caching - a cached old version of a script can look like a code problem. Purge the cache after any change.
Tip

Change one setting at a time and retest, so you know exactly which optimization was responsible.

05. Test and Purge Cache

After any change, purge the Cloudflare cache (Caching then Configuration then Purge Everything) and hard-refresh your browser or test in a private window. Cloudflare serves cached copies, so without a purge you may still see the old, broken behavior and think the fix did not work. See Cloudflare for WordPress for full setup and recommended settings.

Frequently Asked Questions

How do I stop Cloudflare from breaking my JavaScript?

Turn off Rocket Loader in the Cloudflare dashboard under Speed then Optimization, or keep it on and add data-cfasync="false" to the specific script tag it breaks. Then purge the Cloudflare cache and retest.

What is Cloudflare Rocket Loader?

It is a Cloudflare feature that defers and asynchronously loads JavaScript to speed up the first paint. The downside is that scripts needing to run immediately or in order, like sliders and forms, can break.

How do I exclude one script from Rocket Loader?

Add the attribute data-cfasync="false" to that script tag. Cloudflare then leaves that script untouched while still optimizing the others, so you keep the performance benefit without the breakage.

Does disabling Rocket Loader affect caching or SSL?

No. Rocket Loader is independent of Cloudflare's caching, CDN, and SSL, so turning it off only changes how JavaScript loads. Remember to purge the cache after the change so the fix takes effect.

Quick Recap

  1. Rocket Loader defers JS and can break sliders, forms, and embeds.
  2. Disable it in Cloudflare under Speed then Optimization.
  3. Or exclude one script with data-cfasync="false".
  4. Check Auto Minify and caching if a script still breaks.
  5. Purge the cache and hard-refresh after every change.

Cloudflare configuration · Last updated November 2026 · Browse all General articles

Share: X in Reddit f Email
  • 122 Users Found This Useful

Was this answer helpful?

Related Articles

osCommerce password reset

General | Updated November 2026 If you have lost your osCommerce admin password and cannot...

Setting up Zend Framework

Note: This article covers the Zend Framework, which has reached end of life (its successor is...

What is a Top-Level-Domain (TLD)?

General | Updated November 2026 A Top-Level Domain (TLD) is the last part of a domain name,...

PHP RCE Vulnerabilities CVE-2026-109618 and CVE-2026-109619 - Patch Status

Server Security | Updated October 2026 Ultra Web Hosting servers are fully patched against...

How to Create a Support Ticket

General | Updated November 2026 The fastest way to get help with your hosting account is by...



Save 30% on web hosting - Use coupon code Hosting30