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/
Get the height of the viewport
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/
Notify when element size is changed
Check if a node is in the viewport
Find the distance from a given element to the top of the document
Use getVerticalOffset to find the distance from a given element to the top of the document.
Return the current URL
Use Window.location.href to get the URL of the current page.
Calculate the size of scrollbar
The clientWidth property indicates the width without scrollbar. The offsetWidth, on the other hand, includes the scrollbar if there is.
Check If the Document is Ready
To check if the document is ready and execute some code, you bind an event listener to the DOMContentLoaded event of the document object.