javascript - What are best practices for detecting pixel ratio/density? -
i using javascript mobile device detection on website, allows me serve different content mobile or desktop users. currently use window.devicepixelratio , screen.width work out if user if on mobile device or not, so: var ismobilescreenwidth = ((screen.width / window.devicepixelratio) < 768) 768px point @ define mobile or desktop 767 , below mobile , 768 , above desktop. this works perfectly, have come across issue firefox, when firefox zoomed in , out changes window.devicepixelratio , so: zoom = 30%, window.devicepixelratio = 0.3 zoom = 100%, window.devicepixelratio = 1.0 zoom = 300%, window.devicepixelratio = 3.0 this causes me problem because users have browser zoomed in on firefox mobile version of site. i wondering if knew of different or better way of getting pixel density separate desktop browsers. i use small amount of user agent detection because massive job keep changing list of mobile user agents not possible me depend on both screen resolution , user...