
Resolving the script tag type attribute hash prepending issue with Cloudflare
If your script HTML tag has the type attribute prepended with a hash, like <script type="ea10e272b0a1989fb2f3aa4e-text/javascript">...</script> and you’re using Cloudflare services, then the root cause is the Cloudflare Rocket Loader, a feature of Cloudflare that optimizes the loading of JavaScript resources on your web pages.
Rocket Loader modifies the type attribute of script tags for website loading optimization by deferring the loading of JavaScript until after rendering. This modification can cause issues with HTML validation and, when a Content Security Policy (CSP) is active, it requires CSP header updates. Cloudflare’s documentation states that if you have a CSP in place, you must update your headers to support Rocket Loader by adding ajax.cloudflare.com to the script-src directive. Without this, Rocket Loader will not function when a CSP is active.
Cloudflare Rocket Loader adds a type attribute to the script tag, causing issues with the W3C validator due to the “subtype missing” error. Cloudflare’s current Rocket Loader documentation acknowledges this as a known limitation: Some of Cloudflare’s optional features, including Rocket Loader and Email Obfuscation, use non standard tags that fail strict HTML validation via tools like w3.org. These failures do not correlate to issues for your site visitors.







