Skip to content

Instantly share code, notes, and snippets.

@chourobin
Last active December 16, 2015 06:29
Show Gist options
  • Save chourobin/5391663 to your computer and use it in GitHub Desktop.
Save chourobin/5391663 to your computer and use it in GitHub Desktop.
Async Javascript Load
<!-- Sync script will block rendering of page -->
<script type="text/javascript" src="http://link-to-js-assets.js"></script>
<!-- Async script will not block rendering = Preferred Method -->
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript';
po.async = true; po.src = 'http://link-to-js-assets.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment