I think window.innerWidth and window.innerHeight have been standardized, and are okay to use instead of this more complicated alternative.