Find the ratio between physical and device-independent pixels

The ratio between physical and the device-independent pixels (CSS pixels) can be found using window.devicePixelRatio. This ratio is bigger on high-DPI displays and can change if the browser window is moved between screens. There is no way to detect such changes, though.

More information can be found on MDN.