I'm trying to handle JQuery not loading.
(this is for a javascript api, frequently the developer consuming it forgets to include jquery, hence I want to instruct them on what is missing)
- I have a bunch of code in various files that runs on document.ready e.g.
(function ($, undefined) { //stuff })( jQuery );
If JQuery is not loaded then the code above breaks. A workaround I've found is to add a check for Jquery instead through a function e.g.
(function ($, undefined) {
//stuff
})( JQueryCheck() );
function JQueryCheck() {
if (window.jQuery == undefined)
alert("no jquery");
else
return jQuery;
}
I'm not sure if this is strong enough, if theres a better way to do it then let me know.
- On top of this I want prevent the other document.readys from running, theres no point as all depend on JQuery being loaded.
This must be common issue but I'm struggling to find a solution.