I wrote some time ago about Modernizr Server, which runs Modernizr on the client and sends all the Modernizr test results back to the server before any of your actual page is sent, so you can tailor the page to fit whatever device the user is using.
Although this adds an extra HTTP Request and roundtrip to the page request (only on the first request per session because it stores the values and bypasses the tests on subsequent page loads), it could prove to be really beneficial to your users if you can do things like detect whether or not they can use SVG
or canvas
or GeoLocation
, etc., and send them components to take advantage of what their device can do, and serve fallbacks to devices that can’t do that.
Well, I decided to play a little and found it worked really well! Again, page load speed is a little higher on the initial load, but after that there is no penalty.
But I found a couple things:
- I was getting a couple errors from Modernizr tests (CSS Hyphens and MathML);
- I was getting an PHP error in my Modernizr
$_SESSION
variable; and - the Modernizr test results were not available on the final page (neither the JS Object nor the CSS Classes on the
<html>
element).
So, since I’ve recently been diving into GitHub a bit, I decided to figure out Forking and do a little playing. The results:
https://github.com/aarontgrogg/modernizr-server
My changes have been pushed back to James’ repo, hopefully something comes of that, though it could be overkill for some people that don’t intend to use those values on the client.
Anyhow, there it is.
Cheers,
Atg