Skip to content

Instantly share code, notes, and snippets.

@KOWLOR
Forked from joshcarr/window-height-width.js
Last active March 19, 2018 14:08
Show Gist options
  • Save KOWLOR/30c757cbca0fd0caf7a4415c2de618d8 to your computer and use it in GitHub Desktop.
Save KOWLOR/30c757cbca0fd0caf7a4415c2de618d8 to your computer and use it in GitHub Desktop.
vanilla JS window width and height
const getViewportSize = () => {
const e = document.documentElement;
const g = document.getElementsByTagName('body')[0];
const x = window.innerWidth || e.clientWidth || g.clientWidth;
const y = window.innerHeight || e.clientHeight || g.clientHeight;
return {x, y}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment