Advertisement
anatolionobre

[JS] wait for jQuery

Mar 10th, 2014
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function yourFunctionToRun(){
  2.     //Your JQuery goodness here
  3. }
  4.  
  5. function runYourFunctionWhenJQueryIsLoaded() {
  6.     if (window.$){
  7.         //possibly some other JQuery checks to make sure that everything is loaded here
  8.  
  9.         yourFunctionToRun();
  10.     } else {
  11.         setTimeout(runYourFunctionWhenJQueryIsLoaded, 50);
  12.     }
  13. }
  14.  
  15. runYourFunctionWhenJQueryIsLoaded();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement