Created
April 8, 2015 17:36
-
-
Save AsaAyers/eaf0d26a263b779a104d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
cssMonitor: -> | |
@selectors = [] | |
for ss in document.styleSheets | |
for rule in ss.cssRules when rule.selectorText | |
@selectors.push(rule.selectorText) | |
@selectors.sort() | |
isUnused = (sel) -> | |
try | |
$(sel).length == 0 | |
catch | |
return true | |
count = @selectors.length | |
setInterval((=> | |
@selectors = @selectors.filter(isUnused) | |
if count isnt @selectors.length | |
count = @selectors.length | |
console.warn('unused selectors', count) | |
), 1000) | |
getUnusedSelectors: -> @selectors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment