Created
November 12, 2013 12:43
-
-
Save vishaltelangre/7430203 to your computer and use it in GitHub Desktop.
Tiny jQuery plugin to load js files and cache 'em. [#cachefy]
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
# | |
## Cachefy (jQuery Plugin) | |
## @copyright: 2013 (c) Vishal Telangre <the@vishaltelangre.com> | |
## @license: MIT | |
## @desc: Tiny jQuery plugin to load js files and cache 'em. | |
# | |
# | |
jQuery.cachefy = (url, options) -> | |
# Default settings | |
settings = | |
dataType: "script" | |
cache: true | |
url: url | |
# Merge default settings with options. | |
settings = $.extend settings, options || {} | |
# Use $.ajax() since it is more flexible than $.getScript | |
# Return the jqXHR object so we can chain callbacks | |
$.ajax settings | |
# Usage :: | |
# $.cachefy("ajax/test.js").done(function(script, textStatus) { | |
# console.log( textStatus ); | |
# }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment