1. PROMO Get 60% OFF Lifetime Pro Membership & access all our Pro Divi Extensions, Divi Layouts, Divi AI Generator, Divi Block, etc.VIEW PRICING
BEST Divi Block - A revolutionary drag & drop tool to easily mix & match 960+ premade blocks (Light & Dark) to kick start your Divi site design. Special module designs are included as well. Also newly added AI generator & color.
Learn More About Divi BlockFree Version ~ 340+ Free Blocks

Solved The scripts aren't working when I enqueue the default Wordpress jQuery

Discussion in 'Free Divi Community Forum' started by Alfred Balles, Jun 18, 2024.

  1. Alfred Balles

    Alfred Balles New Member

    We are trying to use a plugin: https://support.axcelerate.com.au/h...-WordPress-Requirements-for-Online-Enrolments. And it requires us to use the default jQuery of Wordpress.

    Here is the code that I used on functions.php to do it:
    function my_custom_enqueue_scripts() {
    // Dequeue Divi's jQuery
    wp_dequeue_script('jquery');
    wp_deregister_script('jquery');

    // Enqueue WordPress's default jQuery
    wp_enqueue_script('jquery', includes_url('/js/jquery/jquery.js'), array(), null, true);
    }
    add_action('wp_enqueue_scripts', 'my_custom_enqueue_scripts', 100);

    After doing this, the scripts that I put on Divi > Theme Options > Integration > Add code to the < body > (good for tracking codes such as google analytics) stopped working. And the other scripts that I enqueue on the site shows "jQuery is not defined" error. The site is: https://atiaustralia-dev.tempurl.host/

    Please help
     
    1. PRO MEMBER PERKS Divi Block Pro - Premade testimonial carousel design for your Divi site without using any plugins:View Demo
  2. Divi Booster

    Divi Booster Divi Expert

    Hey Alfred,

    I think you might need to change your wp_enqueue_script call to:

    Code:
    wp_enqueue_script('jquery', includes_url('/js/jquery/jquery.js'), array(), null, false);
    If the last parameter is "true" that tells WP to add the script at the end of the page. This is happening on your site and as such jQuery isn't loaded until after code some of the code on the page tries to use it, resulting in the "jQuery is not defined" errors.
     
  3. Alfred Balles

    Alfred Balles New Member

    thank you Dan!
     
    1. PRO MEMBER PERKS Divi Ultimate Header Plugin - Add more varieties for your Divi header (12 premade styles) + menu hover effects:Learn More
  4. Divi Booster

    Divi Booster Divi Expert

    You're welcome! :)