Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 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";
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
2  
@NickCollins You have forked WordPress now. Be aware this file will be overwritten during the next update. –  toscho Oct 27 '12 at 13:11

Your Answer

 
discard

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.