nit: you don't even really need to define a variable here, do you? Can't you just use window.devicePixelRatio below and delete the scaleRatio variable?  Do we have any devices where devicePixelRatio is not defined?