Modernizr Server Fork: Adding Test Values to the Client Page Too

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:

  1. I was getting a couple errors from Modernizr tests (CSS Hyphens and MathML);
  2. I was getting an PHP error in my Modernizr $_SESSION variable; and
  3. 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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.