Cloudflare Rocket Loader + Wordpress & # 8594; Ignore the scripts?

I am trying to get Cloudflare Rocket Loader to work on my WP site. Everything works fine except for WP Visual Editor. I followed the advice here, but it does not work:

How to add custom attributes to javascript tags in Wordpress?

Cloudflare says that in order for the Rocket Loader to ignore the javascript file, I need to add the data-cfasync = "false" tag in front of my script:

<script data-cfasync="false" src="/javascript.js"></script>    

https://support.cloudflare.com/entries/22063443--How-can-I-have-Rocket-Loader-ignore-my-script-s-in-Automatic-Mode-

The rocket bootloader does not ignore my JS files.

Here is my code:

function rocket_loader_attributes( $url )
{
$ignore = array (

'http://www.mysite.com/wp-includes/js/tinymce/tiny_mce.js?ver=349-21274',
'http://www.mysite.com/wp-admin/js/editor.js?ver=3.4.2'

);
if ( in_array( $url, $ignore ) )
{ // this will be ignored
return "$url' data-cfasync='false";
}

return $url;
}
add_filter( 'clean_url', 'rocket_loader_attributes', 11, 1 );

What is wrong with my code?

I am currently using Rocket Loader in automatic mode.

Can anyone help?

, .

.

+2
2

!

: - Cloudflare

script , . , :

function rocket_loader_attributes_start() {
    ob_start();
}

function rocket_loader_attributes_end() {
    $script_out = ob_get_clean();
    $script_out = str_replace(
      "type='text/javascript' src='{rocket-ignore}", 
      'data-cfasync="false"'." src='", 
      $script_out);  
    print $script_out;
}

function rocket_loader_attributes_mark($url) {
    // Set up which scripts/strings to ignore
    $ignore = array (
        'script1.js'
    );
    //matches only the script file name
    preg_match('/(.*)\?/', $url, $_url);
    if (isset($_url[1]) && substr($_url[1], -3)=='.js') {
      foreach($ignore as $s) {
         if (strpos($_url[1], $s)!==false)
           return "{rocket-ignore}$url";
      }
      return "$url' data-cfasync='true";
    }

    return "$url";

}
if (!is_admin()) {
  add_filter( 'clean_url', 'rocket_loader_attributes_mark', 11, 1);
  add_action( 'wp_print_scripts', 'rocket_loader_attributes_start');
  add_action( 'print_head_scripts', 'rocket_loader_attributes_end');
}
+4

, type='text/javascript'. - Rocket Loader data-cfasync='false' type='text/javascript'... ?

data-cfasync='false', WordPress type='text/javascript', Rocket Loader "" script.

, WordPress, ...

+2

All Articles