Skip to content

Instantly share code, notes, and snippets.

@nlebert-linux
Created May 18, 2015 21:48
Show Gist options
  • Save nlebert-linux/dab36ebe12d952b6c6c8 to your computer and use it in GitHub Desktop.
Save nlebert-linux/dab36ebe12d952b6c6c8 to your computer and use it in GitHub Desktop.
Find HTML elements that are causing overflow and expanding the viewport.
// custom node array iteration function
var nodeArray = function (array, callback, scope) {
for (var i=0; i < array.length; i++) {
callback.call(scope, i, array[i]); // Return each element
}
}
// Document Width
docWidth = document.documentElement.offsetWidth;
nodes = document.querySelectorAll('*');
nodeArray(nodes, function (index, value) {
if (value.offsetWidth > docWidth) {
console.log(value);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment