Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@simevidas
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simevidas/74a1d8a85fefe2cc74bc to your computer and use it in GitHub Desktop.
Save simevidas/74a1d8a85fefe2cc74bc to your computer and use it in GitHub Desktop.
Logging CSS will-change usage on live sites
// Paste this into the browser’s JavaScript console
function walkTheDOM(node, func) {
func(node);
node = node.firstChild;
while (node) {
walkTheDOM(node, func);
node = node.nextSibling;
}
}
walkTheDOM(document.body, function (node) {
if (node.nodeType === 1) {
var willChange = getComputedStyle(node).getPropertyValue('will-change');
if (willChange !== 'auto') {
console.log(`will-change: ${willChange} on element with dimensions: ${node.offsetWidth}x${node.offsetHeight}`);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment