This is a very short post on some useful tidbits I’ve learnt using the ubiquitous jQuery library. I have occasionally found myself in a sticky situation because either (a) the library had not loaded, (b) I’ve been using the wrong version.
We can check if the library is available to us by using either a bang (or two), or using the instanceof
operator. We can use jQuery
and $
interchangeably, as they are aliases.
In the previous example we used window.jQuery
as this will simply result in a truthy output. Using just jQuery
or $
alone with the leading bang will lead to a reference error.
We can get the version number by logging one of the following,
Of course, we would need to know the library had already loaded before checking the version!
Short and sweet!
All the best,
Tom