Created
June 26, 2013 11:04
-
-
Save nmoliveira/5866599 to your computer and use it in GitHub Desktop.
Get javascript file with jQuery. Also let that the file be cached.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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