respond.js or css3-mediaqueries.js ?
The official documentation, especially that of css3-mediaqueries.js, is sparse. Reading on SO, forums and blogs I have summarized these pros and cons.
respond.js
Pros:
- More reliable (? recommended by Modernizr , Twitter Bootstrap 3 and H5BP )
- Lighter (4kb) and faster
- Interpret mediaquery in any context (
<link>, inline CSS, @import-ed CSS)
Cons:
- Doesn’t update on window resize
- Supports only
min-widthandmax-width - Doesn’t support
emunits (huge weak point!)
css3-mediaqueries.js
Pros:
- Reacts in real time (on resize too!)
- Supports
emunits (really? anyone tested it?)
Cons:
- Heavier (15kb) and slower
- Interpret only inline CSS with a explicitly declared media-type
- Lacks detailed documentation and the project seems abandoned
Does anyone have points to add to the list, or personal experiences to share, or a particular preference for one or the other script? If so, why?
I created a test page, including Mediatizr too.
If anyone is interested, here’s the test page, and these are the results (tested on IE8 and IE7).
css3-mediaqueries.js
Pros
min,maxandmin+maxmediaqueriespxandemvalues<style>) and external stylesheetsCons
widthmediaquery<link media="screen and ...">nor@imported stylesheetrespond.js
Pros
min,maxandmin+maxmediaqueriespxandemvaluesCons
widthmediaquery<link media="screen and ...">nor@imported stylesheetson loadevents, to solve it you need to place the script at the end of the pagemediatizr.js
Simply..doesn’t work
In the end I opted for css-mediaqueries.js, conditionally loaded with Modernizr.