Rocket Loader HTML validity is better than it was before but it still causes an error if body tag has an onload

Rocket Loader used to cause severe HTML5 validation errors, there were a few threads about it but it seemed like there was no hope for improvement so I just turned it off for all my domains. But today I noticed things seem to have changed at some point. I tested out turning it back on for all my domains, ran my HTML validation script, and only got errors on a few pages.

After digging into the pages that were throwing errors, it seems that Rocket Loader generates invalid HTML if the body tag contains an onload, in which case it puts the script tag for Rocket Loader between the head and body (illegal)


test1 – body does not have an onload; Rocket Loader script is placed at end of body. Validation status: GOOD

test2 – body does have an onload; Rocket Loader script is placed between head and body. Validation status: FAIL

I’ve found a couple of potential workarounds:

  1. Have the origin add no-transform to the cdn-cache-control header, preventing Cloudflare from making any changes to the page (also disables Analytics/etc)

  2. use Configuration Rules (new-ish CF feature) to turn off Rocket Loader selectively for the pages in question

any other thoughts on this?