Not enough storage is available to complete this operation

I have a pretty large page that doesn’t load MiniProfiler correctly in IE9 because of a javascript error. This same page loads MiniProfiler fine in Chrome.

The javascript error occurs in the /mini-profiler-resources/includes.js?v=… file.

The error is:
Not enough storage is available to complete this operation.
File: includes.js
Line: 521
Char: 21

Looking at the javascript, it is trying to create a new StyleSheet to add to the DOM and can’t.

I’ve looked into this a little more, and I think the error is due to an IE “bug” that doesn’t allow createStyelSheet to be used after there are 31 css references on a page. For reference:

So I think the fix would be to:

  1. Add the style sheet a different way
  2. Handle this exception and when it occurs, fallback to using the workaround discussed in the article. In other words, instead of:



var styleSheet = document.createElement(‘STYLE’);