UNPKG

cache-killer

Version:

A jQuery plugin that refreshes the files on your website

2 lines (1 loc) 1.28 kB
!function(a){function b(a){for(var b=window.location.search.substring(1),c=b.split("&"),d=0;d<c.length;d++){var e=c[d].split("=");if(e[0]==a)return e[1]}}function c(a){for(var b="";b.length<a&&a>0;){var c=Math.random();b+=.1>c?Math.floor(100*c):String.fromCharCode(Math.floor(26*c)+(c>.5?97:65))}return b}function d(a){document.cookie=a+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}function e(a,b,c){var d=new Date;d.setTime(d.getTime()+24*c*60*60*1e3);var e="expires="+d.toUTCString();document.cookie=a+"="+b+"; "+e}function f(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;d<c.length;d++){for(var e=c[d];" "==e.charAt(0);)e=e.substring(1);if(0==e.indexOf(b))return e.substring(b.length,e.length)}return""}function g(){h=f("cacheKiller")}var h,i;a.cacheKiller=function(f){var j=a.extend({css:!0,images:!0,scripts:!0},f);i=b("cacheKiller"),i&&("true"==i?e("cacheKiller",!0,365):d("cacheKiller")),g("cacheKiller"),(h||"true"==i)&&(j.css&&a("html link").each(function(b,d){var e=a(d),f=e.attr("href");f&&e.attr("href",f+"?cacheKiller="+c(5))}),j.images&&a("html img").each(function(b,d){var e=a(d),f=e.attr("src");f&&e.attr("src",f+"?cacheKiller="+c(5))}),j.scripts&&a("html script").each(function(b,d){var e=a(d),f=e.attr("src");f&&e.attr("src",f+"?cacheKiller="+c(5))}))}}(jQuery);