What are best practices for detecting pixel ratio/density?
问题 I am currently using JavaScript for mobile device detection on my website, this then allows me to serve different content for mobile or desktop users. Currently I use window.devicePixelRatio and screen.width to work out if the user if on a mobile device or not, like so: var isMobileScreenWidth = ((screen.width / window.devicePixelRatio) < 768) 768px is the point at which we define mobile or desktop so 767 and below is mobile and 768 and above is desktop. This works perfectly, but I have