简体   繁体   中英

RequireJS not working in IE9

I'm experiencing a fairly peculiar behavior - my RequireJS modules seem to be not initializing and running at all under IE9:

<head>
    ...
    <script data-main="/static/js/main" src="/static/js/libs/require.js"></script> // Seems to be not running at all.
</head>

However, whenever I fire up IE9's developer tool, and reload the page , the modules will be running fine just as they should in Firefox/Chrome/Safari/etc. Cleaning browser cache and closing the developer tool in IE9 will render the JavaScript not running entirely again.

Another way to kick-start the execution of the RequireJS modules is to add a synchronous script calling before it:

<head>
    ...
    <script type="text/javascript" src="https://getfirebug.com/firebug-lite.js"></script> // Add any synchronous script calling here and the module below will execute fine.
    <script data-main="/static/js/main" src="/static/js/libs/require.js"></script>
</head>

It would appear that the reason of the weird behavior may either be:

  • Something went wrong with RequireJS' async loading
  • Something went wrong that caused scripts to launch before $.ready()

Why the developer tool can kick-start the execution really baffled me, though.

Looking for a full explanation to the phenomenon and how to solve it.

Found the answer: console is undefined in IE9 when dev tool is not opened, but you never get to see this error since the tool's console requires a page reload to start working.

More details here: https://github.com/jrburke/requirejs/issues/488

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM