HTMLElement.offsetWidth to get the width of the document.Array.prototype.filter() on the result of Document.querySelectorAll() to check the width of all elements in the document.const getElementsBiggerThanViewport = () => {
const docWidth = document.documentElement.offsetWidth;
return [...document.querySelectorAll('*')].filter(
el => el.offsetWidth > docWidth
);
};
getElementsBiggerThanViewport(); // <div id="ultra-wide-item" />Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️