Webb Food Services

From the to-do list: Dev

✔ see if you can find a way with JS to detect retina screens

Comments

Taylor Bernard on August 5, 2015:

are you not using that retina.js library? it has autodetect built in.

Justin Bernard on August 5, 2015:

no, not on webb.  all the retina stuff is in css.  long story.

Taylor Bernard on August 5, 2015:

what are you trying to use this for if not in the css. need it to be html to redirect or something?

Justin Bernard on August 5, 2015:

in js, some image swapping i am doing

Taylor Bernard on August 5, 2015:

on html side? why not css. already have it in place to image swap there based on pixel ratio aspect?

looks like all retina devices are pixel ratio 2. thats what that '1, 1.5, 2' ect in the pixel ratio is in the css.

Justin Bernard on August 5, 2015:

not html.  in js.  i need a way in js to see if the device is retina or not.

Taylor Bernard on August 5, 2015:

what are you trying to do with it exactly so i can weed some of these methods i found out.

Taylor Bernard on August 5, 2015:

looks like javascript loads last. so isnt the best method for page redirection, ect.

looks like this is the way to go. loads it first and is more powerful.
pretty neat trick.

http://stackoverflow.com/questions/4117555/simplest-way-to-detect-a-mobile-device

Justin Bernard on August 5, 2015:

replacing images via injection from within js

so stuff will be loaded via css, then with user interaction/with js i can change images if need be later on

Taylor Bernard on August 5, 2015:

you need a js lib for detection, then change image via html later. hows that now the retina.js setup?

Taylor Bernard on August 5, 2015:

i thought i linked that one you just sent over earlier. its just using the pixel ratio trick to see if its retina.
i think it may have a known bug though, not that it matters, but i think on some browsers, if you try and zoom. it changes 'pixel ratio' to be higher in a way, thus not true pixel ratio,