php 从Header中删除js脚本并在Footer中排队

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 从Header中删除js脚本并在Footer中排队相关的知识,希望对你有一定的参考价值。

/* Remove jQuery script loading from header */
add_action('wp_enqueue_scripts', 'bh_script_remove_header');
function bh_script_remove_header() {
  
  // You will need to replace the registered name with the name being used on your website
  wp_deregister_script( 'registered-youtube-name' );
        
}

/* Load jQuery script just before closing Body tag */
add_action('genesis_after_footer', 'bh_script_before_end_body');
function bh_script_before_end_body() {
        
  wp_register_script ('youtube-js', 'https://www.youtube.com/yts/jsbin/player-vflmgXZN3/en_US/base.js', array('jquery'), CHILD_THEME_VERSION, true);
  wp_enqueue_script( 'youtube-js' );
                
}

以上是关于php 从Header中删除js脚本并在Footer中排队的主要内容,如果未能解决你的问题,请参考以下文章

JS如何从服务器脚本将数据存储在客户端上

将数据从 HTML 页面发送到 PHP 脚本并在 PHP 中选取数据

xampp通过包含文件链接js文件

HTML5新特性,老生常谈——前端面试常见问题

php 从WordPress脚本/样式中删除脚本版本

php使用正则过滤js脚本代码实例