On my site I have a jquery function which retrieves data from another (secured) server as soon as the page is loaded. Using a jsonp call I currently load this data after doc
I think you could just use
if (jQuery) {
...
}
to see if the jQuery object exists.
Ok, better would be:
if (typeof jQuery !== 'undefined') {
...
}
or
if (typeof jQuery === 'function') {
...
}
EDIT:
Don't worry about the overhead or whether the jQuery object is loaded. If you just include the jQuery library using a regular tag and then execute your code without the
$(document).ready
, like this:
It will work. The $(document).ready
part is only to ensure the DOM has fully loaded before you go around trying to change DOM elements that aren't loaded yet. The jQuery library itself, including the Ajax functionality, will be there right away.
Now, if your initPage(data)
call uses the DOM, which I assume it does, you could put a check in that, like this:
However, I don't think this would be necessary in most situations.