modernizr-server icon indicating copy to clipboard operation
modernizr-server copied to clipboard

[Feature/Library]. Request

Open Darelbi opened this issue 9 years ago • 3 comments

I think the idea of server side capabilities detection is just great. Do you think it is possible to (instead of just "wrapping modernizr.js") do features detection based on user-agent (in a similiar fashion to Mobile-Detect.php library?)

Darelbi avatar Dec 03 '15 13:12 Darelbi

Hmm, it does seem possible, but that's basically what this is already... What additional feature detections would you like to do?

aarontgrogg avatar Dec 03 '15 14:12 aarontgrogg

Actually your library (from what I understand from source code) use client side validation wich is done using javascript features detection, after that data is sent to Server and page is reloaded.

Javascript is clientside code, and some browsers have javascript disabled (in my case I have it disabled by default for all websites except google and few others, I know most users have it enabled by the way but some have it disabled).

If I had time to implement a similiar library (unluckily I have not), I would do that such way:

  1. PHP script that lets you select wich features you want to detect
  2. the script generates another PHP script wich have a hashtable of user agents and requested features
  3. when a client connects the 2nd script gets from hashtable the features (I think in such way there's no reason to even cache features in _SESSION, but that could be figured out only after profiling).

That way no JS is needed. Since compiling manually user-agents can be cumbersome it can be done in automatic way (in example the modernizr-server library could already creates key-values maps for UserAgent=>FeatureX that can be used by 1st script to generate the 2nd script).

Darelbi avatar Dec 03 '15 21:12 Darelbi

You could do that, and many companies do; it is called device detection (or something similar). Feature detection must happen in the browser. Any such data that you store somewhere is not, and would require constant maintenance. That's the beauty of feature detection: it can load in any browser, and instantly know what it can and cannot, do.

And while it is true that some devices do not have JS (or have it turned off), research has shown that to be a very, very small audience, and is almost always someone that did so intentionally, meaning they know what they are getting into...

Anyway, that's the beauty of our industry: you can always fork and customize. :-)

Cheers!

aarontgrogg avatar Dec 04 '15 08:12 aarontgrogg