在这个文件中
wp-include/script-loader.php
有这个代码:
$scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ), '1.11.3');
$scripts->add( 'jquery-core', '/wp-includes/js/jquery/jquery.js', array(), '1.11.3');
$scripts->add( 'jquery-migrate', "/wp-includes/js/jquery/jquery-migrate$suffix.js", array(), '1.2.1');
如何将 jquery 放在页脚中?
我已经尝试添加第五个参数“true”或“1”,但不起作用。
...
* Localizes some of them.
* args order: $scripts->add( 'handle', 'url', 'dependencies', 'query-string', 1 );
* when last arg === 1 queues the script for the footer
...
我想将 jquery 放在底部,因为它会阻止正确的页面加载(谷歌页面速度推荐)。
最佳答案
您必须先将其出列,然后再将其入列。 以下代码将完全满足您的需求。
function jquery_mumbo_jumbo()
{
wp_dequeue_script('jquery');
wp_dequeue_script('jquery-core');
wp_dequeue_script('jquery-migrate');
wp_enqueue_script('jquery', false, array(), false, true);
wp_enqueue_script('jquery-core', false, array(), false, true);
wp_enqueue_script('jquery-migrate', false, array(), false, true);
}
add_action('wp_enqueue_scripts', 'jquery_mumbo_jumbo');
关于php - 页脚上的 Wordpress jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35663927/