jquery.js延迟解析存在问题。问题是,WordPress中的“添加新帖子”显示白色,屏幕上没有任何内容。其余的一切工作正常。
这是代码
function defer_parsing_of_js ( $url ) {
if ( FALSE === strpos( $url, '.js' ) ) return $url;
if ( strpos( $url, 'jquery.js' ) ) return $url;
return "$url' defer ";
}
add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
答案 0 :(得分:0)
function defer_parsing_of_js($url)
{
//Specify which files to EXCLUDE from defer method. Always add jquery.js
$files = array('jquery.js');
//let's not break back-end
if (!is_admin()) {
if (false === strpos($url, '.js')) {
return $url;
}
foreach ($files as $file) {
if (strpos($url, $file)) {
return $url;
}
}
} else {
return $url;
}
return "$url' async='async";
}
add_filter('clean_url', 'defer_parsing_of_js', 11, 1);