How to check what version of jQuery is loaded?

Jquery

Jquery Problem Overview


How do I check which version of jQuery is loaded on the client machine? The client may have jQuery loaded but I don't know how to check it. If they have it loaded how do I check the version and the prefix such as:

$('.class')
JQuery('.class')

Jquery Solutions


Solution 1 - Jquery

if (typeof jQuery != 'undefined') {  
    // jQuery is loaded => print the version
    alert(jQuery.fn.jquery);
}

Solution 2 - Jquery

You can just check if the jQuery object exists:

if( typeof jQuery !== 'undefined' ) ... // jQuery loaded

jQuery().jquery has the version number.

As for the prefix, jQuery should always work. If you want to use $ you can wrap your code to a function and pass jQuery to it as the parameter:

(function( $ ) {
    $( '.class' ).doSomething();  // works always
})( jQuery )

Solution 3 - Jquery

My goto means to determine the version:

$.fn.jquery

Another similar option:

$().jQuery

If there is concern that there may be multiple implementations of $ — making $. ambiguous — then use jQuery instead:

jQuery.fn.jquery

Recently I have had issues using $.fn.jquery and $().jQuery on a few sites so I wanted to note a third simple command to pull the jQuery version.

> If you get back a version number — usually as a string — then jQuery is loaded and that is what version you're working with. If not loaded then you should get back undefined or maybe even an error.

Pretty old question and I've seen a few people that have already mentioned my answer in comments. However, I find that sometimes great answers that are left as comments can go unnoticed; especially when there are a lot of comments to an answer you may find yourself digging through piles of them looking for a gem. Hopefully this helps someone out!

Solution 4 - Jquery

…just because this method hasn't been mentioned so far - open the console and type:

$ === jQuery

As @Juhana mentioned above $().jquery will return the version number.

Solution 5 - Jquery

I have found this to be the shortest and simplest way to check if jQuery is loaded:

if (window.jQuery) {
    // jQuery is available.

    // Print the jQuery version, e.g. "1.0.0":
    console.log(window.jQuery.fn.jquery);
}

This method is used by http://html5boilerplate.com and others.

Solution 6 - Jquery

My preference is:

console.debug("jQuery "+ (jQuery ? $().jquery : "NOT") +" loaded")

Result:

jQuery 1.8.0 loaded

Solution 7 - Jquery

In one line and the minimum of keystrokes (oops!):

alert($().jquery);

Solution 8 - Jquery

You should actually wrap this in a try/catch block for IE:

// Ensure jquery is loaded -- syntaxed for IE compatibility
try
{
	var jqueryIsLoaded=jQuery;
	jQueryIsLoaded=true;
}
catch(err)
{
	var jQueryIsLoaded=false;
}
if(jQueryIsLoaded)
{
	$(function(){
		/** site level jquery code here **/
	});
}
else
{
	// Jquery not loaded
}

Solution 9 - Jquery

Go to the developer's Tool > console and write one of the following command jQuery.fn.jquery console.log(jQuery().jquery);

Solution 10 - Jquery

As per Template monster blog, typing, these below scripts will give you the version of the jquery in the site you are traversing now.

 1. console.log(jQuery.fn.jquery);
 2. console.log(jQuery().jquery);

Solution 11 - Jquery

Maybe self explanatory, but simplest method I have found is looking at the version commented in the actual file (typically jquery.min.js). Alternatively,if something like code.jquery.com is used, version number is in https reference (ie https://code.jquery.com/jquery-1.11.3.js).

enter image description here

Solution 12 - Jquery

if (jQuery){
   //jquery loaded
}

.....

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLuke101View Question on Stackoverflow
Solution 1 - JqueryDarin DimitrovView Answer on Stackoverflow
Solution 2 - JqueryJJJView Answer on Stackoverflow
Solution 3 - JqueryRockin4Life33View Answer on Stackoverflow
Solution 4 - JqueryptimView Answer on Stackoverflow
Solution 5 - JqueryMarkus Amalthea MagnusonView Answer on Stackoverflow
Solution 6 - Jquerysshel207View Answer on Stackoverflow
Solution 7 - JqueryDavid WhiteView Answer on Stackoverflow
Solution 8 - JqueryAlienWebguyView Answer on Stackoverflow
Solution 9 - JquerySuman KoiralaView Answer on Stackoverflow
Solution 10 - JqueryaniruddhaView Answer on Stackoverflow
Solution 11 - JqueryMarkView Answer on Stackoverflow
Solution 12 - JquerygenesisView Answer on Stackoverflow