Skip to content

Instantly share code, notes, and snippets.

@attilagyorffy
Forked from attaboy/gist:1346280
Created November 9, 2011 16:24
Show Gist options
  • Save attilagyorffy/1351966 to your computer and use it in GitHub Desktop.
Save attilagyorffy/1351966 to your computer and use it in GitHub Desktop.
Destroy the localStorage copy of less.js client-side-generated CSS
// Destroys the localStorage copy of CSS that less.js creates
function destroyLessCache(pathToCss) { // e.g. '/css/' or '/stylesheets/'
if (!window.localStorage || !less || less.env !== 'development') {
return;
}
var host = window.location.host;
var protocol = window.location.protocol;
var keyPrefix = protocol + '//' + host + pathToCss;
for (var key in window.localStorage) {
if (key.indexOf(keyPrefix) === 0) {
delete window.localStorage[key];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment