Use jQuery to load scripts asynchronously
// Load scripts asynchronously | |
jQuery.loadAsync = function(url, callback) { | |
// Don't use $.getScript since it disables caching | |
jQuery.ajax({ | |
'url': url, | |
'dataType': 'script', | |
'cache': true, | |
'success': callback || jQuery.noop | |
}); | |
}; |
This comment has been minimized.
This comment has been minimized.
Yeah, I’ve pinged @kswedberg about it — he’ll be adding it to the documentation page for |
This comment has been minimized.
This comment has been minimized.
$.getScript support caching when using the options object signature like this:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Good tip. This is basically what
$.getScript()
does, but with thecache
AJAX option, right? I was surprised to find that$.getScript()
does not accept this option itself :/