Instead, you can load scripts using the cache:
var scriptTag = document.createElement("script"); scriptTag.type = "text/cache"; scriptTag.src = "http://thirdparty.com/foo.js"; scriptTag.onreadystatechange = scriptTag.onload = function() { if (scriptTag.readyState == "loaded" || scriptTag.readyState == "complete") {
This will cause scripts to load in the background, like an image; you can call them directly if they load. The caveat is that if you have multiple timeouts, it can consume all available outgoing connections. If you serialize third-party Javascripts only then they should make the most of one connection.
This is the method used by head.js. You can probably just use head.js, but you can add extra logic for what to do with timeouts, etc.
source share