Home / Archive / Add data-no-optimize to all JS snippets
Duplicate Snippet

Embed Snippet on Your Site

Add data-no-optimize to all JS snippets

This snippet filters the output of all the WPCode JavaScript snippets to add the data-no-optimize parameter that indicates to the LiteSpeed Cache plugin to ignore the script from minification.

<10
Code Preview
php
<?php
add_filter( 'wpcode_snippet_output_js', function( $code ) {
	$code = str_replace( '<script>', '<script data-no-optimize="1">', $code );
	return $code;
});

Comments

Add a Comment