Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript To Use WP jQuery or Not?

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #46167
    ethanmiller
    Participant

    I’ve heard a lot of strong opinions expressed about whether one should de-queue the version of jQuery that is included with WordPress or not. Here on this site there’s a [snippet for including jQuery via google](https://css-tricks.com/snippets/wordpress/include-jquery-in-wordpress-theme/).

    I’ve done it both ways on different sites and I don’t think I’ve ever run into any trouble. What do you all think? In fact, I’ve never understood why there are such strong opinions about whether one should do this or not. What are the trade-offs here? Would love to get to the bottom of this.

    #141737
    Billy
    Participant

    The thing is that if people are using the WordPress version, there is a greater chance of it being cached, because WP will be using a fixed version.

    Using the Google version, which is a CDN (so it’s very fast) may have more or less caching depending on the version you use, but its non-cached loading speed will be faster.

    I don’t think that the speed makes too much difference unless you’re loading lots of js scripts and images, etc.

    #141748
    gilgimech
    Participant

    No you always want to use the built in version of jQuery with WordPress. The reason is, if there’s a plugin that needs jQuery that plugin will use the default WP version (or at least it should) and if you load a different version you might run into version conflicts.

    I had this happen on a site a client asked me to fix. There were three different version of jQuery loaded on one page, and causing a plugin not to work.

    And you always want to use wp_enqueue_script() so you don’t have multiple instances of if loading.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.