Defer loading of javascript - exclude url

Hi there,
i tried to implement the defering of js

I tried that the script should exclude all “/x/” urls, sothat cornerstone and headerbuilder are working.
unfortunately although its not defering, the pagebuilder or headerbuilder is not loading.

Is there another script that shall excluded?

( FALSE === strpos ( “$_SERVER[REQUEST_URI]” ,’/x/’) )

if (!(is_admin() ) &&  ( FALSE === strpos ( "$_SERVER[REQUEST_URI]" ,'/x/')     )   ) {
	function defer_parsing_of_js ( $url ) {
		if ( FALSE === strpos( $url, '.js' ) ) return $url;
		if ( strpos( $url, 'jquery.js' ) ) return $url;
		if ( strpos( $url, 'cs-head.js' ) ) return $url;
		if ( strpos( $url, 'cs.js' ) ) return $url;
		if ( strpos( $url, 'cs-vendor.js' ) ) return $url;
		// return "$url' defer ";
		return "$url' defer onload='";
	}
	add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
}

Or maybe i should better set defer to async ?


aarrgg. its not working. Thread can be deleted
I shall better use W3 total cache plugin.^^

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.