How to Check if jQuery Is Loaded on a Page Using JavaScript

Does the current website have jQuery loaded, and if so —which version is loaded? Here’s how to find out if the popular JavaScript library is available on a webpage or in the browser console.

Dr. Derek Austin 🥳
Coding at Dawn

--

Photo by Joshua Earle on Unsplash

Checking if jQuery Is Loaded With JavaScript

Modern browser consoles have a built-in dollar sign operator ($()) that is an alias for the commonly-used function document.getElementByID(), which selects an HTML element on the page using its ID attribute.

“The dollar sign is commonly used as a shortcut to the function document.getElementById().” — Stephen Chapman at ThoughtCo

Of course, most JavaScript programmers are familiar with the $() function from jQuery, not as an alias of document.getElementByID().

Since any browser console is going to have a $() function, how can you tell if that function is the built-in version or the jQuery version?

The $() function in jQuery is also an alias — this time, for the function jQuery(), which is a selector function more similar to document.getElementsByTagName() than document.getElementByID().

“jQuery() […] can…

--

--

Dr. Derek Austin 🥳
Coding at Dawn

I write about real-world programming career advice, MongoDB vs. PostgreSQL, Git, React, JavaScript, VS Code, TypeScript, and Next.js. Doctor of Physical Therapy