Created
June 25, 2013 11:44
-
-
Save benfoxall/5857853 to your computer and use it in GitHub Desktop.
quick function to find which selectors aren't being used.
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
function each(items,fn){[].forEach.call(items,fn)} | |
each(document.styleSheets, function(sheet){ | |
each(sheet.cssRules, function(r){ | |
try{ | |
// look for the first matching element | |
if(!document.querySelectorAll(r.selectorText)[0]) | |
console.log("Unused Selector: ", r.selectorText); | |
} catch (e){ | |
console.log('unable to process', r.selectorText, e) | |
} | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment