Credit

All credit goes to the original author, John Pham.

Problem

A horizontal scroll bar appears on your website, and it's not immediately obvious which element is causing it.

Solution

Copy and paste this snippet into your browser console, it will log all the elements that are causing the horizontal scroll.
const documentWidth = document.documentElement.offsetWidth;

document.querySelectorAll("*").forEach((node) => {
	if (node.offsetWidth > documentWidth) {
		console.log(node);
	}
});