Skip to content

Instantly share code, notes, and snippets.

@vishaltelangre
Created November 12, 2013 12:43
Show Gist options
  • Save vishaltelangre/7430203 to your computer and use it in GitHub Desktop.
Save vishaltelangre/7430203 to your computer and use it in GitHub Desktop.
Tiny jQuery plugin to load js files and cache 'em. [#cachefy]
#
## 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