Wordpress有很好的工具来处理脚本依赖关系,您应该使用它。您可以从以下内容开始:
一般来说,不建议加载外部jQuery,但如果确实要加载,则必须从WP core注销jQuery副本,然后注册自己的副本或从CDN:
add_action(\'wp_enqueue_scripts\', \'wpse_scripts\');
function wpse_scripts() {
//Uncomment the next two lines if you want to load jquery from Google CDN
//wp_deregister_script(\'jquery\');
//wp_register_script( \'jquery\', \'//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js\', false );
//Pajinate depends on jquery
wp_register_script( \'pajinate\', $plugins_url."/mistral/js/jquery.pajinate.js", array(\'jquery\') );
//In the next file include your functions and code that depends on jquery and pajinate
wp_register_script( \'my-script\', $plugins_url."/mistral/js/your-script.js", array(\'jquery\', \'pajinate\') );
//Now you are ready to load enqeue the registered scripts
wp_enqueue_script(\'jquery\');
wp_enqueue_script(\'pajinate\');
wp_enqueue_script(\'my-script\');
}