javascript - How can I check for/use jQuery in closure loaded before jQuery? -
i have js file contains closure, file loaded before jquery, let's can't moved. how can pass in or check jquery view use in closure?
this i've got far:
(function myclosure() { var interval = setinterval(function() { if (typeof jquery !== 'undefined') { dojquerystuff(); clearinterval(interval); } }, 500); function dojquerystuff() { // stuff jquery. } })();
it works, there "better" way? think i'm doing wrong whenever use setinterval()
things this, fact losing time in 500ms.
you wait , attach execution window.onload
event, assuming jquery loaded once window loaded...
window.onload = function() { // stuff jquery };
Comments
Post a Comment