Get the document height and width

Get the document height

// Full height, including the scroll part
const fullHeight = Math.max(
document.body.scrollHeight, document.documentElement.scrollHeight,
document.body.offsetHeight, document.documentElement.offsetHeight,
document.body.clientHeight, document.documentElement.clientHeight

Get the document width

// Full width, including the scroll part
const fullWidth = Math.max(
document.body.scrollWidth, document.documentElement.scrollWidth,
document.body.offsetWidth, document.documentElement.offsetWidth,
document.body.clientWidth, document.documentElement.clientWidth


Get the closest element by given selector
Get the parent node of an element