I have a few files causing issues when i'm using cloudflare's rocket loader. But it improves my site speed by 0.5 sec.
I work inside the Wordpress environment, and as you all properly know, you can't directly edit the html.
My quesiton is: Is it possible to add data-cfasync="false" attribute via a PHP filter or action to a my scripts? So it would look like this:
<script data-cfasync="false" src="/javascript.js"></script>
I tried the filter below, but didn't work..
add_filter( 'script_loader_tag', function ( $tag, $handle ) {
if ( 'jquery.min.js' !== $handle )
return $tag;
return str_replace( "type='text/javascript' src", ' data-cfasync="false" src', $tag );
}, 10, 2 );