There are two methods to get the viewport width: window.innerWidth and document.documentElement.clientWidth. The former is more accurate. The latter has better browser support. To get the best of both worlds, try innerWidth first, and fallback to clientWidth if not supported. Source https://vanillajstoolkit.com/reference/viewport/viewport-width/
There are two methods to get the viewport height: window.innerHeight and document.documentElement.clientHeight. The former is more accurate. The latter has better browser support. To get the best of both worlds, try innerHeight first, and fallback to clientHeight if not supported. Source https://vanillajstoolkit.com/reference/viewport/viewport-height/
Use getVerticalOffset to find the distance from a given element to the top of the document.
Use Window.location.href to get the URL of the current page.
The clientWidth property indicates the width without scrollbar. The offsetWidth, on the other hand, includes the scrollbar if there is.
To check if the document is ready and execute some code, you bind an event listener to the DOMContentLoaded event of the document object.