我有一个网站在 Google Page Speed Insights 上得分很高,但它显示了一个性能问题,并显示此文件的“删除未使用的 JavaScript”:
https://www.gstatic.com/recaptcha/releases/2diXFiiA9NsPIBTU15LG6xPf/recaptcha__en.js https://www.gstatic.com/recaptcha/releases/2diXFiiA9NsPIBTU15LG6xPf/recaptcha__en.js
但是,我尝试删除我的 Invisible Captcha 插件,并将这行代码添加到functions.php中:
add_action('wp_print_scripts', function () {
if ( is_home() ){
wp_dequeue_script( 'google-recaptcha' );
wp_dequeue_script( 'google-invisible-recaptcha' );
}
});
但我仍然收到错误。我可以采取什么措施来删除此脚本在我的主页上的加载吗?我的网站正在使用最新版本的 Wordpress。
以下对我有用:
add_action( 'wp_enqueue_scripts', 'mytheme_deregister_scripts' );
function mytheme_deregister_scripts() {
if( is_home() || is_front_page() ) :
wp_deregister_script('google-invisible-recaptcha');
endif;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)