创建一个插件,将您不需要的javascript排出队列,并将已编辑的javascript排入队列。
<?php
/**
* Plugin Name: Stackexchange Sample
* Author: Nathan Johnson
* Licence: GPL2+
* Licence URI: https://www.gnu.org/licenses/gpl-2.0.en.html
* Domain Path: /languages
* Text Domain: stackexchange-sample
*/
//* Don\'t access this file directly
defined( \'ABSPATH\' ) or die();
add_action( \'wp_enqueue_scripts\', \'wpse_106269_enqueue_scripts\', 15 );
function wpse_106269_enqueue_scripts() {
$slb = SimpleLightbox::get_instance();
wp_dequeue_script( \'simplelightbox-call\');
wp_deregister_script( \'simplelightbox-call\' );
wp_register_script( \'simplelightbox-edit\',
plugins_url( \'/simplelightbox-edit.js\', __FILE__ ),
[ \'jquery\', \'simplelightbox\' ], false, true);
wp_localize_script( \'simplelightbox-edit\', \'php_vars\', $slb->options );
wp_enqueue_script( \'simplelightbox-edit\' );
}
编辑:我刚刚在一个新的安装上测试了上述插件,它将“simplelightbox调用”javascript退出队列,并将编辑的脚本排入队列。