Skip to content

Instantly share code, notes, and snippets.

@Jakobud
Last active May 20, 2021 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jakobud/d0047d728f1f72ba151776a0078713cb to your computer and use it in GitHub Desktop.
Save Jakobud/d0047d728f1f72ba151776a0078713cb to your computer and use it in GitHub Desktop.
Inline JS scripts when using deferred dependencies
<!-- 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