Enquire.js + Media.match + Respond.js

I am trying to get Enquire.js to work for legacy browsers. I use the Deep support method from the docs:

Modernizr.load([ { test: window.matchMedia, nope: "media.match.min.js" }, "enquire-2.0.0.min.js", "plugins.js", // jquery plugins "main.js" // enquire-triggered functions + general code ]); 

The problem with this is that I am using Modernizr + Reply from initializr.com, so the test always passes. This causes a JS error in enquire.js in IE8 / 9.

By removing response.js and just using simple Modernizr, the test failed, Media.match loads and the JS error is resolved. However, I am losing support for Media Query in IE8.

What is the best way to make everything work together? I tried loading response.js simultaneously with Media.match via Modernizr. If I download it first, I see the same JS error as before. If I download the second, media queries do not work. I also tried just loading this INSTEAD from Media.match, but the JS error is returning.

Thanks.

EDIT:

Shortly after posting this post, I rolled back to request 1.5.6, use Respond.js, the shouldDegrade option, and Modernizr tests. There are no JS errors in IE8 / 9, and everything seems to be working fine so far.

I'm still curious to know if there is a way to get this to work with 2.0, or if I should stick with 1.5.6 at the moment?

+4
source share
3 answers

I ran into the same issue with Inquire v2.0.2. My workaround was to remove the inclusion of matchMedia from response.js and then load media.match and enquire.js after loading reply.js. I have not tested this with modernizr yet, but I managed to get support for media queries and enquire.js to work in IE7 and 8 without JS errors.

+4
source

I assume the actual problem is that in response.js you have matchMedia polyfill, but without the matchMedia.addListener plugin . Thus, the modernizr test for plain matchMedia succeeds, but then leads to the error you are likely to get with the request (the object does not support this property or method).

I myself do not like to configure response.js so as not to include matchMedia, but just download the matchMedia.addListener plugin separately after response.js.

+1
source

Tim,

A little late, but have you seen it yet? I think this is what you are looking for.

enquire.js deprecated support

0
source

All Articles