• I cannot figure out how jQuery is inserted into the head section of my site. Is it likely that one of my plugins are doing so? If that’s the case, then how would subsequent plugins detect that it’ already being called?

    Secondly, how do I know that it’s being updated? I would rather control it in my child theme’s header.php

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    If the code is done properly, jQuery is inserted via wp_enqueue_script. Subsequent properly written plugins and code will not load extra copies. jQuery is shipped with WordPress to ensure that a consistent version is available.

    See https://developer.wordpress.org/reference/functions/wp_enqueue_script/

    Thread Starter Revived

    (@revived)

    So jQuery is part of the WP core files and not something added by my theme (Responsive)?

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Your theme, if properly written, does something like

    wp_enqueue_script( ‘jquery’ );

    to add the main jQuery code.

    I say “properly written” because one could grab jQuery from a number of places and load it in many different ways. If you get your theme from a place like wordpress.org/themes, it will do it the proper way.

    So, what are YOU trying to accomplish in your child theme?

    If you’re loading a script that relies on jQuery, you just have to declare ‘jquery’ in your array of dependencies when you load your own scripts via wp_enqueue_script.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How is jQuery inserted/updated?’ is closed to new replies.