I have found out JQuery is loading twice on my Wordpress website and is causing some plugins to break. I have done some research and think I need to remove some JQuery code from the header.php
file, and then insert some new JQuery code into the functions.php
file. Trouble is I am not exactly sure what code to remove/add. Can anyone help me stop JQuery running twice?
To remove the default WordPress jQuery file you can use the following:
function remove_jquery(){
wp_deregister_script('jquery');
wp_dequeue_script('jquery');
}
add_action('wp_enqueue_scripts','remove_jquery');
That should deregister and dequeue the native jQuery file and keep the one that you have in your header.php file.
function dequeue_script() {
wp_dequeue_script( 'jquery' );
}
add_action( 'wp_print_scripts', 'dequeue_script', 100);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.