1// create an Observer instance
2const resizeObserver = new ResizeObserver(entries =>
3 console.log('Body height changed:', entries[0].target.clientHeight)
4)
5
6// start observing a DOM node
7resizeObserver.observe(document.body)
8
9// click anywhere to rnadomize height
10window.addEventListener('click', () =>
11 document.body.style.height = Math.floor((Math.random() * 5000) + 1) + 'px'
12)