IE: "Stack overflow at line: 0" #86

matthewwithanm opened this Issue Nov 30, 2011 · 15 comments


None yet

10 participants


I started getting this dreaded error while testing a page using Modernizr. Eventually I tracked it down to the MQ Polyfill option. To reproduce it, just add a lot of stylesheets (> 13) to a document. I haven't dug into the source, but it seems likely that the issue is explained by this article.


Thanks! Sounds fixable. I'll take a look today.


I ran into the same issue in IE7. I tracked it down to the recursive makeRequests call in the ajax callback. Wrapping the call in a setTimeout seems to clear it up for me.


Hi, I saw this issue today and the fix suggested by rico55 worked a treat.


I don't know that that's so much a fix as a workaround.


The article matthewwithanm linked to describes the correct problem: If you have more than 12 css files in your HTML you get the error. Instead of a workaround I just combined my css files.

I think it is enough to mention this as a limitation in the readme.



I've been using Respond on a Magento site. I've split Magento's massive style.css file into many smaller files and respond seems to work absolutely fine with 25 css files in IE but fails when you add just one more. I can't be 100% on the number but I think that's correct.

Scott, do you have any idea if this is an IE recursion bug similar to that linked to above? The actual error fromthe console in IE dev tools is:

SCRIPT87: Invalid argument.
respond.src.js, line 268 character 12




Also running into this issue with 21 CSS files, removing respond.js or compiling the files into a smaller number (for production) fixes the issue. no good in development though. found this which seems relevant:


Still happening :D boo.


Hi scottjehl, this is a pretty easy fix, think you can add it in?

Simply wrap line 102 in a setTimout function like this:

setTimeout(function() { makeRequests(); },0);


Everyone's mind will rest easier if the script does the best it can for everyone without passing judgement.

Right now, when the script fails, it fails only for IE and it fails with a non-descriptive error message. That is frustrating and confusing for users. Yes, users with some skill may eventually stumble across this thread and read about how they should use fewer CSS files, but not before having struggled and lost a bunch of time. And while it is important to combine and compress CSS files in a production environment, it sometimes makes sense to be verbose in a test environment.

If you feel compelled to use this as a learning opportunity, don't let IE7 be the messenger. Instead, count the number of css files and add a descriptive popup that says something like "Whoa, that's a lot of CSS files! Read this article for more info." But even that, I would argue, undermines the elegance of this simple, wonderfully-useful, works-out-of-the-box script.


For what it’s worth, even IE7 itself fails (silently, I believe) above 31 stylesheets.

Given that the objective of this project was to provide a fast, lightweight polyfill for common media queries and given the performance overhead involved with parsing though 20+ stylesheets, I think the maintainer is within his rights to pass on accounting for this edge case. You might want to look into, which is a more enterprise-class media query polyfill.


I have 15 stylesheets and the script fails. Upon reviewing the link below, I suspect the problem actually occurs with 13+ stylesheets.


PR sent! Take a look.

@scottjehl scottjehl closed this in c1736e7 Oct 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment