Skip to content

Instantly share code, notes, and snippets.

@mathiasbynens
Created September 6, 2011 09:44
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save mathiasbynens/1197140 to your computer and use it in GitHub Desktop.
Save mathiasbynens/1197140 to your computer and use it in GitHub Desktop.
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
});
};
@oriadam
Copy link

oriadam commented Jul 5, 2017

$.getScript support caching when using the options object signature like this:

$.getScript({
    url: "foo.js",
    cache: true
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment