Created
July 14, 2015 14:37
-
-
Save cssence/41c8279810b1db71670d to your computer and use it in GitHub Desktop.
List all used CSS classes
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 listAllUsedClassNames () { | |
var classNames = {}; | |
Array.prototype.forEach.call(document.querySelectorAll("*"), function (element) { | |
if (typeof element.className === "string") { | |
element.className.split(" ").forEach(function (className) { | |
if (className) { | |
classNames[className] = true; | |
} | |
}); | |
}; | |
}); | |
//console.log(Object.keys(classNames).sort().join("\n")); | |
return Object.keys(classNames); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment