// START Defer parsing, credit Ethan Chin in the Divi Web Designers
Facebook group
add_filter( 'script_loader_tag', 'defer_scripts', 10, 3 );
function defer_scripts( $tag, $handle, $src ) {
// The handles of the enqueued scripts we want to defer
$defer_scripts = array(
'jquery-core',
);
if ( !in_array( $handle, $defer_scripts ) && !current_user_can(
'update_core' ) ) {
return '<script src="' . $src . '" defer="defer"
type="text/javascript"></script>' . "n";
}
return $tag;
}
// END Defer parsing
Code language: PHP (php)Defer parsing of scripts
Last updated:
Categories: Uncategorized