WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My site uses cloudflare but I really want to enable rocket loader, but if I put it on automatic mode, it messes up my whole site...

So I googled and found This answer which has helped in terms of adding the data-cfasync="true" or the data-cfasync="true" tags (see cloudflare wiki for this) to the script tag. But it ads it AFTER the URL. For rocket loader to use the tag, it needs to be straight after the opening script tag. So basically:

<script data-cfasync="true(or false)" type="text/javascript" src="domain.com/jshere.js"></script>

The answer on the page above (here) gives instructions on how to do it, I added it to my functions.php file and it added the tag on the relevant URL. But it adds the code after the URL and thus is pointless because rocket loader does not see the tag as it is after the url.

I am no good at php and I have been playing with the code for a day to try and get the tag to go before the URL but I can't seem to do it. I am wondering if anyone can modify that code for the functions.php so this can be accomplished?

share|improve this question

I am afraid this is impossible. The markup is hard coded in /wp-includes/class.wp-scripts.php:

if ( $this->do_concat )
    $this->print_html .= "<script type='text/javascript' src='$src'></script>\n";
    echo "<script type='text/javascript' src='$src'></script>\n";
share|improve this answer
You have actually answered my question and fixed the problem lol I just edited /wp-includes/class.wp-scripts.php line 78 changed from echo "<script type='text/javascript'>\n"; // CDATA and type='text/javascript' is not needed for HTML 5 to echo "<script data-cfasync='false' type='text/javascript'>\n"; // CDATA and type='text/javascript' is not needed for HTML 5 This then fixed my problem and the page is displaying correctly! – Nick Collins Oct 27 '12 at 12:46
@NickCollins You have forked WordPress now. Be aware this file will be overwritten during the next update. – toscho Oct 27 '12 at 13:11
@toscho Forked? I'd say knifed. – Andrei Gheorghiu Feb 4 '15 at 23:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.