Created
May 1, 2017 17:41
-
-
Save vladimirmyshkovski/f1676427a09257170f9b62a15d124249 to your computer and use it in GitHub Desktop.
Wait to load defer scripts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function defer(method) { | |
if (window.inputmask) // Important! Wait loading last script! | |
method(); | |
else | |
setTimeout(function() { defer(method) }, 50); | |
} | |
<script> | |
<script type="text/javascript" defer src="js/jquery-3.2.1.min.js"></script> | |
<script type="text/javascript" defer src="js/bootstrap-3.3.7.min.js"></script> | |
<script type="text/javascript" defer src="js/jquery.inputmask.3.3.4.min.js"></script> | |
<script> | |
defer(function () { | |
alert("jQuery is now loaded"); | |
// CODE | |
}); | |
</script> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function defer(method) { | |
if (window.jQuery) | |
method(); | |
else | |
setTimeout(function() { defer(method) }, 50); | |
} | |
<script> | |
<script> | |
defer(function () { | |
alert("jQuery is now loaded"); | |
// CODE | |
}); | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment