Skip to main content
CSS-Tricks
  • Articles
  • Notes
  • Links
  • Guides
  • Almanac
  • Picks
  • Shuffle
Search
Snippets → jQuery Code Snippets → Check if jQuery is Loaded

Check if jQuery is Loaded

Chris Coyier on Nov 5, 2009
if (typeof jQuery == 'undefined') {

    // jQuery IS NOT loaded, do stuff here.

}
Psst! Create a DigitalOcean account and get $200 in free credit for cloud-based hosting and services.

Comments

  1. Ben
    Permalink to comment# November 6, 2009

    I usually do alert($);

    Loading...
    Reply
  2. Sarfraz Ahmed
    Permalink to comment# July 16, 2010

    or

    alert(jQuery);

    Loading...
    Reply
  3. Sunny Verma
    Permalink to comment# December 11, 2013

    use
    if (typeof jQuery == 'function')
    or
    if (typeof $== 'function')

    to check if jQuery is Loaded

    Loading...
    Reply
  4. jamal
    Permalink to comment# March 3, 2014

    if(jquery) will do tjob

    Loading...
    Reply
  5. jamal
    Permalink to comment# March 3, 2014

    if (jQuery) {
    alert(“jquery is loaded”);
    } else {
    alert(” Not loaded”);
    }

    Loading...
    Reply
  6. kaustubh
    Permalink to comment# February 3, 2017

    you can open developer console and type $ to check if jQuery is loaded or not

    Loading...
    Reply
    • tim
      Permalink to comment# July 18, 2017

      genius

      Loading...
  7. Jannis
    Permalink to comment# November 16, 2017

    checking just for “$” as some people suggest is certainly NOT enough to check for jQuery existence. Some websites may dont use jQuery in general but like the “$” function and just slice out this part from the jQuery library. Or they make their own like const $ = (elem) => document.querySelectorAll(elem); In both cases if you check for “$” you would get a function back even though jQuery is not existing. I agree with the people who check for the jQuery object –> if(window.jQuery).

    Loading...
    Reply

Leave a Reply Cancel reply

CSS-Tricks is powered by DigitalOcean.

Keep up to date on web dev

with our hand-crafted newsletter

DigitalOcean
  • About DO
  • Cloudways
  • Legal stuff
  • Get free credit!
CSS-Tricks
  • Contact
  • Write for CSS-Tricks!
  • Advertise with us
Social
  • RSS Feeds
  • CodePen
  • Mastodon
  • Bluesky
Back to Top
%d