Browser size (width and height)

browser, javascript, jquery

Solution

// first get the size from the window
// if that didn't work, get it from the body
var size = {
  width: window.innerWidth || document.body.clientWidth,
  height: window.innerHeight || document.body.clientHeight
}

Problem

I'm trying to detect the browser's current size (width and height). I know it's super easy in jQuery with `$(document).width and $(document).height`, but I don't want to add the size of the jQuery lib to the project, so I'd rather just use built in JavaScript. What would be the short and efficient way to do the same thing with JavaScript?

Original source

Related problems