Cloudflare Pages CSS not working on custom domain: fix
Cloudflare Pages CSS or JS broken on your custom domain but fine on .pages.dev? Check Rocket Loader and other zone settings, with exact steps.
The Liite team7 min di lettura
Short answer
Your custom domain goes through your Cloudflare zone, so zone features like Rocket Loader apply there but not on .pages.dev. Turn Rocket Loader off at Speed > Settings > Content Optimization, purge the cache, and retest in a private window.
Your site looks right at yourproject.pages.dev, but on your own domain the styles are missing or the scripts misbehave. In plain terms:
cloudflare pages css not working custom domain
People on Reddit threads about HTML deployed to Pages report this, and in the cases we found, turning off Rocket Loader fixed it. That makes it the most likely cause, not a certainty for every site.
Why it happens
Your files are the same on both addresses. What differs is what sits in front of them. Cloudflare's Pages documentation says that when a proxied CNAME record points your custom domain to Pages, requests pass through your zone first, so your WAF, Redirect Rules, Transform Rules, Cache Rules and Bot Management settings apply. Rocket Loader is one of those zone-level features.
Most common causes, in order:
- Rocket Loader. It defers the loading of all your JavaScript until after rendering. Cloudflare says it keeps order of execution, but scripts that depend on timing can still break. Cloudflare's own troubleshooting advice is: if you see JavaScript or jQuery issues, disable Rocket Loader and retest.
- Rocket Loader markup already in your files. One report involved a static WordPress export with Rocket Loader code baked into the HTML. Turning the setting off won't remove it.
- A stale cached copy. A broken version can linger at the edge or in your browser after you change a setting.
- Other zone rules. Transform Rules, Cache Rules, a WAF rule or a Cloudflare Access policy on the domain can block or alter asset requests. Cloudflare lists Automatic HTTPS Rewrites, Cloudflare Fonts, Email Address Obfuscation, Polish, Rocket Loader and other dynamic transformations as features that change content in transit.
- Mixed content or wrong paths in the HTML. Hard-coded
http://URLs or the old.pages.devhostname.
Auto Minify is often mentioned in older threads. Cloudflare has been retiring it, so it may not exist on your account. I could not confirm its current status from Cloudflare's docs, so treat it as a lower-probability suspect.
Fix 1: turn off Rocket Loader
- Confirm what is failing. Open developer tools on the broken domain. In Network, look for CSS or JS requests that fail. In Console, look for script errors. Real 404s are a different problem (see the table below).
- In the Cloudflare dashboard, go to the Speed > Settings page, then Content Optimization.
- Switch Rocket Loader to Off.
- Purge the cache for the domain in the caching section of the dashboard.
- Reload in a private window, or hard refresh, and compare with the
.pages.devversion.
To apply the setting to specific hostnames instead of the whole zone, use a configuration rule. That is handy if other sites on the same zone benefit from Rocket Loader.
Tip
Change one setting at a time and retest. If the page works after Rocket Loader goes off, you know which feature to keep disabled.
Keep Rocket Loader on, but exclude one script
You can have Rocket Loader ignore a script by adding the data-cfasync="false" attribute to its tag. Cloudflare's limits to know: dependencies of that script need the attribute too, and it must come before the src attribute.
<script data-cfasync="false" src="/js/app.js"></script>If it only affects one page, Cloudflare suggests a Configuration Rule that excludes that page by URL.
Fix 2: remove Rocket Loader code from an exported site
A static export (for example from WordPress) can contain Cloudflare-specific markup in the HTML, such as script tags whose type was rewritten. The dashboard toggle does nothing about that.
- Search your exported HTML for
rocket-loaderandcloudflare. - Re-export from the original site with Rocket Loader off, or remove the rewritten attributes and restore normal
<script src="...">tags. - Redeploy to Pages and purge the cache.
Fix 3: check the other causes
- Mixed content. If the Console says an insecure request was blocked, change
http://asset URLs tohttps://or to relative paths. Do the same for any hard-coded.pages.devhostname. - MIME type errors. A message that a stylesheet or script was blocked because of its MIME type means the file is being served as something else. In Network, open the file and check its
Content-Type. HTML where CSS should be usually means the path returns a fallback page. - Zone rules. Review Transform Rules, Cache Rules and WAF rules that match your hostname. Temporarily disable one at a time.
- Access policies. Cloudflare's Pages docs say that if no Access policy is configured for your custom domain, an authentication page can render but not work for visitors. This applies if you enabled Access on your Pages project.
Cause, symptom and fix
| Cause | What you see | Fix |
|---|---|---|
| Rocket Loader | Page loads, scripts run late or fail | Turn it off or exclude the script |
| Baked-in Rocket Loader markup | Still broken after toggling off | Re-export, redeploy |
| Stale cache | Old broken copy persists | Purge, hard refresh |
| Mixed content | Console says blocked insecure request | Use https:// or relative paths |
| Wrong MIME type | Console names MIME type | Check the file path and headers |
| Real 404 | Network tab shows 404 on assets | Check the deployment and paths |
Note
Cloudflare moves dashboard items around. The paths above match its docs as of November 2026. If yours differs, search the dashboard for "Rocket Loader".
What won't help
- Redeploying the same files. They work on
.pages.dev, so the build is not the problem. - Rewriting CSS paths that already load elsewhere.
- Waiting for DNS. If a page loads but looks broken, DNS has already resolved.
Checklist before you try again
- Rocket Loader is off for the hostname, or the script has
data-cfasync="false". - The exported HTML has no
rocket-loaderleftovers. - Cache is purged and you tested in a private window.
- Asset URLs are
https://or relative. - No zone rule or Access policy matches the hostname unexpectedly.
If nothing works
Contact Cloudflare support through your dashboard, or use the Cloudflare Pages docs and status page. Include the failing URL, the Network tab status and headers of one broken file, the exact Console error, the time you tested, and the settings you already changed.
Subject: Pages CSS/JS fails on custom domain, works on .pages.dev
Hello, my Pages project works at <project>.pages.dev but the CSS/JS
is broken at <yourdomain.com>. Rocket Loader is off, I purged the cache
and tested in a private window. The failing file is <URL>, which returns
<status/MIME type> at <time, timezone>. Console error: "<paste error>".
Please check whether a zone setting or rule is changing this file.Common questions
Why does .pages.dev work but my domain does not?
Your custom domain's requests pass through your own Cloudflare zone, and its rules and features apply there. The .pages.dev address does not use your zone's settings.
Do I need to turn Rocket Loader off for my whole account?
No. It is a per-zone setting, and you can limit it to certain hostnames with a configuration rule.
Is my custom domain not working at all, or just the CSS?
If the page does not load or shows an error like 522, that is a domain setup issue. Cloudflare's docs say manually adding a CNAME without first associating the domain in the Pages dashboard results in a 522 error. See Cloudflare's custom domains documentation.
If your site is just finished HTML
Liite doesn't run build pipelines or Git deploys, so it won't replace Cloudflare Pages for a built project. If you already have finished HTML, you can upload the file, a zip or a folder and get a live site, with a custom domain on Pro and up. See putting an HTML file, zip or PDF online.