0

I use this code:

if ( ! function_exists( 'WPScripts_enqueue' ) ) {
    function WPScripts_enqueue() {

        // Removing default jQuery
        wp_deregister_script( 'jquery' );

        // Enqueue the new jQuery
        wp_enqueue_script('jquery', 'https://code.jquery.com/jquery-3.2.1.slim.min.js', false, '3.2.1', false);

        // Enqueue custom Bootstrap file
        wp_enqueue_style('bootstrap', get_template_directory_uri() . '/css/bootstrap.css', array(), false, 'all');

    }
}
add_action('wp_enqueue_scripts', 'WPScripts_enqueue');

however, wp still load jquery from wp core:

https://developers.google.com/speed/pagespeed/insights/?hl=TR&url=http%3A%2F%2Fwww.migrate2.deniz-tasarim.site%2Fhomepage%2F&tab=desktop

https://i.ibb.co/qxhCY6R/image.png

0

Use the Following sequence to override jquery
Install latest jQuery version 3.4.1. Update the following sequence of code and try!!!!

      wp_deregister_script('jquery');
      wp_register_script('jquery',("https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"), 
   false);
      wp_enqueue_script('jquery');

I hope it will help you!!!

| improve this answer | |
0

Add priority to add_action.

add_action('wp_enqueue_scripts', 'WPScripts_enqueue', 999);

Or

add_action('wp_enqueue_scripts', 'WPScripts_enqueue', -1);
| improve this answer | |
-1

You have to first dequeue the script first & then deregister the script as given as bellow

           wp_dequeue_script( 'jquery');

           wp_deregister_script(‘jquery’);

Try this!!

| improve this answer | |
  • it doesnt work.it is still same – ahmet kaya Feb 13 at 19:09
  • Are you sure that WPScripts_enqueue is being executed? – Cadu De Castro Alves Feb 13 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.