• A WP Life

    (@awordpresslife)


    I am using a plugin with the theme and getting error Uncaught ReferenceError: jQuery is not defined but in the page source, jquery is loaded then why showing the error?

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • This theme does not use jQuery, so the fault must be with your plugin.

    Thread Starter A WP Life

    (@awordpresslife)

    But we enqueue the inbuilt jquery.

    
    //wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
    wp_enqueue_script( 'jquery' );
    

    Thanks

    • This reply was modified 5 years, 8 months ago by A WP Life.
    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Perhaps your plugin uses jQuery before it is output on the page – but that would be a plugin issue.

    Thread Starter A WP Life

    (@awordpresslife)

    The plugin enqueuing the js in the plugin’s shortcode file code.

    How can I determine like when will the plugin’s shortcode enqueue js on the page load?

    Can you guide us? Do I need some hook/action to load jquery before page output?

    Thanks for the reply.

    • This reply was modified 5 years, 8 months ago by A WP Life.
    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Look at the page source – View the Webpage, right click and press ‘view source’ (or a similarly named option).

    Search for where jQuery is being enqueued and note down its line number.
    Then search for where your plugin JS is being enqueued.

    Your plugin JS should be after the jQuery script in the page source.


    The other time I’ve seen a similar error to what you’ve described is when the plugin loads its own version of jQuery (which is bad) and then you end up with 2 instances of jQuery.

    Thread Starter A WP Life

    (@awordpresslife)

    Thanks and perfect trick to track. Will check and get back to you if need any help.

    The script that uses jQuery should be enqueued with array('jquery') as the dependency parameter. That way they will be output in the correct order.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘JQuery Error’ is closed to new replies.