Add attribute to jquery
-
Hi,
I would like to add the attribute
data-cfasync="false"
(which is used to tell Cloudflare to disable rocket loader for that specific script) but I can’t find a way to do itI was trying the filter
function wpse_script_loader_tag( $tag, $handle ) { if ( 'jquery' !== $handle ) { return $tag; } return str_replace( ' src', ' data-cfasync="false" src', $tag ); } add_filter( 'script_loader_tag', 'wpse_script_loader_tag', 10, 2 );
But it doesn’t work
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Add attribute to jquery’ is closed to new replies.