如何防止 wordpress 加载对 js 文件和 css 文件的所有调用。这样你就只有生成wordpress的html文件了?
更准确地说,我正在使用 child 主题。我可以编辑 function.php
文件。我用过:
wp_deregister_style( '(句柄) ' );
wp_dequeue_style("(句柄)");
wp_dequeue_script( '(句柄)' );
wp_deregister_script('(句柄)');
但对于许多句柄不起作用,我搜索(如果存在)一个脚本,该脚本可将所有调用一并删除。
最佳答案
在您的 WordPress 子主题 functions.php 文件中:
function childtheme_prefix_remove_scripts() {
if ( is_page(25655) ) {
wp_dequeue_style( 'handle' );
wp_dequeue_script( 'handle' );
}
}
add_action('wp_enqueue_scripts', 'childtheme_prefix_remove_scripts', 999);
关于javascript - 如何在一页wordpress中禁用所有脚本和样式表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59413556/