Also 

    var innerWidth = global.innerWidth || document.body.clientWidth

might be a bit more elegent.