Skip to content

Instantly share code, notes, and snippets.

@max-kk
Created September 15, 2016 14:17
Show Gist options
  • Save max-kk/33d81371e3c9eb59c6d1f1b6f50f3c43 to your computer and use it in GitHub Desktop.
Save max-kk/33d81371e3c9eb59c6d1f1b6f50f3c43 to your computer and use it in GitHub Desktop.
text/rocketscript excluder
<?php
add_filter( 'script_loader_tag', function ( $tag, $handle ) {
//var_dump($handle);
$handles_to_exclude = array('fv_main_js'=> 0,'fv_theme_story'=>0, 'fv_lib_js'=>0, 'fv_evercookie'=>0, 'jquery-core'=>0, 'jquery-migrate'=>0);
if ( !isset($handles_to_exclude[$handle]) ) return $tag;
if ( 'fv_main_js' == $handle ) {
global $wp_scripts;
$tag = '<script data-cfasync="false">' . $wp_scripts->print_extra_script( $handle, false ) . '</script>' . $tag;
}
return str_replace( "type='text/javascript' src", ' data-cfasync="false" src', $tag );
}, 0, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment