Skip to content

Instantly share code, notes, and snippets.

@nmoliveira
Created June 26, 2013 11:04
Show Gist options
  • Save nmoliveira/5866599 to your computer and use it in GitHub Desktop.
Save nmoliveira/5866599 to your computer and use it in GitHub Desktop.
Get javascript file with jQuery. Also let that the file be cached.
jQuery.cachedScript = function(url, options) {
// allow user to set any option except for dataType, cache, and url
options = $.extend(options || {}, {
dataType: "script",
cache: true ,
url: url
});
// Use $.ajax() since it is more flexible than $.getScript
// Return the jqXHR object so we can chain callbacks
return jQuery.ajax(options);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment