Skip to content

Instantly share code, notes, and snippets.

@cssence
Created July 14, 2015 14:37
Show Gist options
  • Save cssence/41c8279810b1db71670d to your computer and use it in GitHub Desktop.
Save cssence/41c8279810b1db71670d to your computer and use it in GitHub Desktop.
List all used CSS classes
(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