Last active
May 20, 2021 05:35
-
-
Save Jakobud/d0047d728f1f72ba151776a0078713cb to your computer and use it in GitHub Desktop.
Inline JS scripts when using deferred dependencies
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
<!-- Example: Load jQuery using defer --> | |
<script defer src="path/to/jquery.js"></script> | |
<!-- Inline script that waits for deferred jQuery to load before executing --> | |
<script> | |
window.addEventListener('DOMContentLoaded', function() { | |
(function($) { | |
// Put your custom code here | |
})(jQuery); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment