JavaScript Async Callback 0.0.1
DO NOT USE THIS: See this HN thread for more details: http://news.ycombinator.com/item?id=4473121.
USE THIS INSTEAD: https://gist.github.com/3620903#comments
<1kb global helper function called _async
, which loads external scripts asynchronously with callbacks.
Works across all browsers, see Compatibility.
Live Demo
View the live demo.
Quick Start
Add the script to the <head>
of your document (or before all other scripts using _async
):
<script src="//raw.github.com/niftylettuce/javascript-async-callback/master/async.min.js"></script>
Then asynchronously load a script with a callback function:
(function liveDemo() {
var src = '//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js'
function callback() {
alert('It works!')
}
_async.load(document, src, callback)
}())
... and you're done!
Compatibility
IE | FF | Chrome | Safari | Opera | iOS | Opera Mini | Android | Blackberry | Opera Mobile | Chrome Android | Firefox Android |
---|---|---|---|---|---|---|---|---|---|---|---|
5.5+ ✓ | 2.0+ ✓ | 4.0+ ✓ | 3.1+ ✓ | 9.0+ ✓ | 3.2+ ✓ | 5.0+ ✓ | 2.1+ ✓ | 7.0+ ✓ | 10.0+ ✓ | 18.0+ ✓ | 15.0+ ✓ |
Contributors
- Nick Baugh [email protected]
License
MIT Licensed