Skip to content

Instantly share code, notes, and snippets.

@adamrobbie
Created June 28, 2012 17:24
Show Gist options
  • Save adamrobbie/3012660 to your computer and use it in GitHub Desktop.
Save adamrobbie/3012660 to your computer and use it in GitHub Desktop.
js to load js without blocking .onload() via Stoyan
(function(url){ var iframe = document.createElement('iframe'); (iframe.frameElement || iframe).style.cssText = "width: 0; height: 0; border: 0"; var where = document.getElementsByTagName('script'); where = where[where.length - 1]; where.parentNode.insertBefore(iframe, where); var doc = iframe.contentWindow.document; doc.open().write('<body onload="'+ 'var js = document.createElement(\'script\');'+ 'js.src = \''+ url +'\';'+ 'document.body.appendChild(js);">'); doc.close(); })('http://www.jspatterns.com/files/meebo/asyncjs1.php');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment