0

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?

1 Answer 1

1

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";
else
    echo "<script type='text/javascript' src='$src'></script>\n";
3
  • 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! Commented Oct 27, 2012 at 12:46
  • 3
    @NickCollins You have forked WordPress now. Be aware this file will be overwritten during the next update.
    – fuxia
    Commented Oct 27, 2012 at 13:11
  • 1
    @toscho Forked? I'd say knifed.
    – tao
    Commented Feb 4, 2015 at 23:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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