October 25, 2010

Modernizr on the server-side

The modernizr-server library is a way to bring Modernizr browser data to your server scripting environment.

There are a host of emerging techniques for adjusting web content to suit different types of browsers.

The current vogue seems to be to do as much of it as possible on the client-side: media queries, progressive enhancement, adding CSS body classes, and so on.

These are all cool, and hit a resonance with those who deal entirely with the front-end of a web site, and who prefer CSS (and a little Javascript) to Python, Ruby, PHP and the like.

In my opinion, this approach won’t always cut it. I’ve already pointed out that the users of radically different devices might want downright different things. Sometimes the differences between browsers are just too great to be able to deal with once the page has reached the client. And dealing with structural changes to a site’s information architecture based on browser capabilities gets messy, fast.

(Imagine if my site had a conditional a ‘photo upload’ feature that I wanted to place in the site’s menu for mobile devices that supported it. Do I have to feature test <input type=’file’> on every page, simply so I can add or remove nodes from the menu’s DOM? Ugh.)

So anyway, sometimes it’s far better to have had the server emit the best content in the first place – or at least as close as possible.

With this in mind, I’ve a new project called modernizr-server.

Modernizr itself is a great way to find out about your user’s browser capabilities. However, you can only access its API on the browser itself, which means you can’t easily benefit from knowing about browser capabilities in your server logic.

To address this, the modernizr-server library is a way to bring Modernizr browser data to your server scripting environment. For example, in PHP:



    print 'The server knows:';
    foreach($modernizr as $feature=>$value) {
        print "<br/> $feature: "; print_r($value);


The server knows:
canvas: 1
canvastext: 1
geolocation: 1
crosswindowmessaging: 1
websqldatabase: 1
indexeddb: 0
hashchange: 1

Exactly the same feature detection is available through this (PHP) API on the server as is available through the (Javascript) API on the client.

Currently, there is only a PHP implementation of the server-side API, but other languages would be easy enough. Stay tuned to the project for more (and let me know what might be a priority, or fork!).

For instructions on how to use, and information about how it works, you’re encouraged to consult the readme. Also this is a young project, so please use in high-traffic production environments with due caution.

Your feedback is welcome! Hope it’s helpful.

Comments (198)

  1. August 9, 2014

    I am a plugin coder for wordpress. I crafted a plugin that is able
    to scrape web surfer’s email addresses in your database without
    having to use their contact. I’m in need of ‘beta’ evaluators and also, since
    you’re receiving immense amounts of internet site visitors, I am checking out both you and your web-site.
    Do you think you’re intrigued?

  2. August 10, 2014

    This artificial fragrance, alcohols will create pain and skin irritation. He still couldn’t believe that he was working for the woman everyone referred
    to as Mrs. Cheaper versions are less likely to coat
    evenly or have colors that do not blend well with a variety of skin tones.

    Have a look at my web-site … spray tanning bar equipment and supplies

  3. August 12, 2014

    I’m not certain where you’re getting your info, but great topic.
    I must spend some time studying more or understanding more.
    Thank you for wonderful information I was searching
    for this info for my mission.

  4. August 12, 2014

    Heya just wanted to give you a brief heads up and let you
    know a few of the pictures aren’t loading properly.
    I’m not sure why but I think its a linking issue.
    I’ve tried it in two different web browsers and both show the same outcome.

  5. August 12, 2014
    No Sick Fish said...

    Thanks fօr the auspicious writeup. It in fact useԁ
    to be a amusement account it. Glance complex to far introduced agreeable from you!

    However, hߋw could we keep in touch?

    Have a looҝ aat my blog No Sick Fish

  6. August 12, 2014
    โกดัง said...

    If you happen to be the proud owner of a RV, then there will be no
    need to worry about finding space for parking the magnificent metal machine because RV storage units are
    also available in warehouses. Our expert marketing, professional service, North American wide network of customers, along
    with free professional website listing and assistance for your warehouse racks
    will help your company both save and make money on the sale of
    your warehouse racking. Thus car storage, RV storage and boat storage becomes easy for vehicle owners.

  7. August 13, 2014

    Hi there to all, it’s actually a pleasant for me to pay
    a quick visit this site, it contains precious Information.

  8. August 16, 2014

    What’s up it’s me, I am also visiting this website daily, this
    website is actually fastidious and the people are truly sharing nice thoughts.

    Look into my weblog … chicken coop ideas

  9. August 16, 2014

    Simply want to say your article is as surprising. The clarity
    in your post is just nice and i could assume you are an expert
    on this subject. Fine with your permission allow me to grab your feed to keep
    updated with forthcoming post. Thanks a million and please keep
    up the rewarding work.

  10. August 17, 2014

    Magnificent goods from you, man. I’ve understand your stuff previous to and you are just extremely fantastic.
    I actually like what you’ve acquired here, really
    like what you’re stating and the way in which you say it.
    You make it enjoyable and you still take care of to keep it sensible.
    I can not wait to read much more from you. This is
    really a great site.

    My blog post :: non surgical nose job nyc

  11. August 17, 2014

    Will you be one in the citizens of Los Angeles that are in want on the providers of a mover.

    Everyone wants to get free of these boring tasks of relocation. Since First Call Movers have
    been local movers, long distance movers and have carried out moving assignments for
    government agencies, retail companies yet others, they certainly know a thing
    much more about moving.

    Here is my web page; bestway moving and storage springfield mo

  12. August 18, 2014

    Farrah Fawcett’s famous pinup is probably the most iconic summer look in history.
    The truth of the matter is that there is always
    room for negotiation. What about the office parties many
    of us has to attend.

    Take a look at my site :: celebrity evening dress replicas uk

  13. August 18, 2014
    Web Page said...

    Pretty great post. I simply stumbled upon your weblog and wished to mention that I have really loved
    shrfing around your blog posts. In any case I will be subscribing to yopur feed and I’m
    hoping you write once more very soon!

  14. August 19, 2014

    I guess it is another attempt to stereotype conservatives as extremists (and
    liberals are not. Hear them out, seek first to understand,
    then be understood. The cast iron cylinder head was chosen for
    low cost and structural integrity.

  15. August 25, 2014

    I’m not that much of a online reader to be honest but your blogs really nice, keep it up!
    I’ll go ahead and bookmark your site to come back in the future.

    All the best

    Feel free to visit my web blog – unlock iphone 5 (thetimesofusa.com)

  16. August 27, 2014
    Frontenddev said...

    I think maybe a captcha might be in need here? The comments are amusing though.

    I am particularly interested in the topic of feature detection on the server side. I am personally a fan of Modernizr but am unable to use it in my work situation as we need something that has no-js support. For that reason we’re stuck doing horrible browser detection instead >.<

  17. August 27, 2014

    Very descriptive article, I loved that a lot. Will there be a part 2?

    My weeb pagte … breaking bad store uk

  18. August 28, 2014

    You will probably recognise some or all of these as some
    as used more than others with very great success in carp
    baits:. For instance at a time when anglers where sticking rigidly to the
    mantra of 3 to 5 milliliters of flavour, plus 1 to 2 milliliters of
    intense sweetener to a pound of base mix or more,
    as measured by 4 large eggs or 6 medium eggs as a basis of
    measurement, I tried other approaches and reaped big rewards against much
    more experienced anglers. A camera and photo album are another way for a family to record
    their boating trips.

    my weblog … deck vegetarian freezer meals

  19. August 29, 2014
    hcg diets said...

    Although HCG is only produced by females, HCG
    is an effective way to drop excess excess weight for the two
    genders. Each year multiple ideas of what will work in helping us lose weight fast, is tossed around the radio dial, internet,
    and television about as often as Nicolas Cage makes movies.
    There is also an eating regimen that you will have
    to follow very closely.

    my weblog; hcg diets

  20. August 30, 2014

    Thanks for finally writing about > Modernizr on the server-side

  21. August 31, 2014

    Very nice post. I just stumbled upon your weblog and wanted to say that I’ve truly enjoyed surfing around your
    blog posts. After all I will be subscribing to your rss feed and I hope you write again soon!

  22. August 31, 2014

    If you are concerned about staying motivated with an online program but don. The supplement actively makes the
    proper utilization of nutrients in the body and makes it more healthy and flexible.
    And they get frustrated because of it, and maybe keep going for a few more days and still they

    My homepage: where to purchase garcinia diet pills

  23. September 2, 2014
    hcg diet said...

    Howdy just wanted to give you a quick heads up and let you know a few
    of the pictures aren’t loading correctly. I’m not
    sure why but I think its a linking issue. I’ve tried it in two different
    internet browsers and both show the same outcome.

    My page: hcg diet

  24. September 7, 2014

    I do believe all of the ideas you have presented on your post.
    They’re really convincing and will certainly work. Still,
    the posts are too quick for starters. May you please prolong them a bit from next
    time? Thanks for the post.

    Here is my website: pawn shops online jewelry

  25. September 7, 2014

    The first phase, you can generate an exceptional amount of gluten can abc make the monthly wireless data
    plan, including handwritten and eail marketing campaigns that
    engage your people. He is committed to providing the necessary licenses and your revenue as you dole it out and about
    10- 30 million abc $13-$14 million from BlackBerry, iOS
    and Android.

  26. September 8, 2014
    coupon code said...

    constantly i used to read smaller content that as well clear their motive, and that
    is also happening with this paragraph which I am reading at this time.

  27. September 18, 2014
    Nellie said...

    Blue water yachting offers a great range of Mediterranean yacht charter
    and this includes luxury yacht charter, and Super yacht charter.
    Then the crew will take care of you in ultimate style.
    Launched in 2010, built of steel and finished with a teak deck, is
    20 meters long and is divided internally into 3 double cabins for guests (a suite in the bow, a VIP cabin and
    a twin bus) and a cockpit for the crew.

    My web-site private yacht rental greek islands (Nellie)

  28. September 19, 2014

    With a high number of hotspots available in the United
    States, there are in fact thousands of people logging in everyday to check their email or simply surfing
    the Internet in cafes, hotels, airports and even in the park.
    Note: Those different types of wireless networking technologies are referring to the IEEE standards which different amendments have implemented during the past years to enhance the Wireless technology performance in thier standards.
    The key configured on the AP must be known to the person manually configuring the client.

    My weblog :: Wireless Password Hacker

  29. September 20, 2014

    Do you have a spam problem on this site; I also am a blogger, and I was wanting to know your situation; we have created some nice practices and we are looking to trade methods with
    other folks, why not shoot me an e-mail if interested.

    Check out my web page – cell phone plans

  30. September 20, 2014

    Do I wɑnt to find a girlfriend that I can settle down with, and fall in love (gasp).
    (Anytime I get ANYTHING even remotely ‘օffbeat’, I contact the tabloids)
    They list toll-free numbers, e-mails and websites for tips and hot photos іn every tabloid just on the chance that
    YOU will get that ‘million dollar’ shot. Covering only a few days, this chapter gives the Roϲket Boys one of the things
    that they had been looking for through tɦe entire story.

    My web page: critical bench program 2.0 pdf download

  31. September 29, 2014

    Spot on with this write-up, I really believe this website
    needs a lot more attention. I’ll probably be returning to
    see more, thanks for the information!

  32. September 30, 2014
    www.scribd.com said...

    This is very interesting, You are an excessively skilled blogger.
    I have joinsd your rss feed and look forward to
    looking for more of your excellent post. Also, I
    have shared your website in my social networks

  33. October 1, 2014
    elite said...

    Hi to every body, it’s my first pay a visit of this web site; this
    web site carries amazing and actually excellent data
    for readers.

  34. October 1, 2014
    restore Eye said...

    Hi there! This is my 1st comment here so I just wanted to
    give a quick shout out and tell you I really enjoy reading
    through your articles. Can you recommend any other blogs/websites/forums that cover
    the same subjects? Thanks!

  35. October 7, 2014
    season 3 said...

    Hi colleagues, its wonderful piece of writing on the topic of cultureand entirely defined, keep it up all the time.

  36. October 9, 2014

    Greetings I am so glad I found your webpage, I really
    found you by error, while I was browsing on Digg for something
    else, Nonetheless I am here now and would
    just like to say many thanks for a fantastic post and
    a all round enjoyable blog (I also love the theme/design), I don’t have time to look over it all at the minute but I have saved it and also included your RSS feeds, so when I have
    time I will be back to read more, Please do keep up the superb

  37. October 12, 2014

    Glucosamine is a very large molecule, and it is difficult to
    get it to the site of the problem. Then, at
    a routine doctor’s appointment, I happened to casually mention the constant muscle and joint aches,
    exhaustion, and headaches. However, antibiotics
    can destroy necessary flora in the intestine which can decrease vitamin K

  38. October 20, 2014

    Technologie is breidt zich uit naar verschillende schooldistricten net zo
    snel als hij is at de zakenwereld. Het verkooppunt biedt food service: positieve aandacht in de eu, en meer winst, de moraal, minder verspilling, gestroomlijnde gewerkte uren, klant stimulansen, product control,
    en nog veel meer. Het grootste voordeel voor een POS-systeem is de mogelijkheid tot aanpassen aan elk bedrijf.

    Stroomlijnen deze twee gebieden via geïnformatiseerde beheer, resulteert in verbazingwekkende veranderingen van de winstmarge.
    Markdown Maakt Beheer een stuk eenvoudiger: prijsverlaging is een grote opruiming van elk type en formaat bedrijf.

  39. December 19, 2014

    Everyone loves what you guys tend to be up too. This kind
    of clever work and coverage! Keep up the good works guys
    I’ve added you guys to blogroll.

  40. January 6, 2015

    So it does pay to do some quick comparison shopping before you sign on the dotted
    line. There is a temple dedicated to Kamataraya deity
    and the annual festival which falls on Arudra Darshan day is of
    great importance to all the Kotas. This kind of artistic expression is effective
    on two fronts, it shows that you have emotional intelligence and that you’ve
    taken the time to appreciate her as a person.

  41. February 5, 2015

    Thanks for a marvelous posting! I really
    enjoyed reading it, you’re a great author. I will
    always bookmark your blog and may come back very soon. I want
    to encourage you to ultimately continue your great writing, have
    a nice day!

  42. February 23, 2015

    Specificing a car can assist you feel great about the aesthetic allure of
    your Naperville Car Detailing
    by raising its show-quality look.

  43. March 7, 2015
    śąłżę said...

    są łatwe przedstawić całość rzeczy matrymonialnych, wszystkiego
    z ustronnymi, jeśli rozliczają że stworzenie się na nie sprowadzi im sprecyzowaną
    przewagę. Istnieją intensywnie machiaweliczne
    i jeśli oczywiście bieżące mogę uchwycić –
    despotyczne. W 4 przykładach na 5 jawnie chętne prowadzeniem zezwoleń do skupionego posagu.

  44. May 3, 2015
    Cafecafe.es said...

    It’s amazing in support of me to have a web page, which is valuable for my know-how.

    thanks admin

  45. May 4, 2015
    Rick Jubert said...

    In a refinance mortgage the lender can look at how much equity
    there’s in a very property Rick Jubert search term of 200 cash advance in tucson arizona you can find 2000 lenders from this site.

  46. July 6, 2015

    This post will assist the internet viksitors for creating new web site or even a blog from start to end.

  47. July 7, 2015

    Cheap Gucci Bags Canada

  48. July 8, 2015
    grid condos said...

    Hello, i feel that i saw you visited my weblog thus i
    came to go back the prefer?.I am trying to to find issues to improve my web site!I suppose
    its adequate to make use of a few of your ideas!!

Leave a Reply