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:
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.
Syntax. define(['module1', 'module2'], function (module1, module2) { //define the module value by returning a value return function () {}; }); You can pass a list of module names when you define a module and RequireJS can be used to retrieve these modules before executing the module.
To include the Require. js file, you need to add the script tag in the html file. Within the script tag, add the data-main attribute to load the module. This can be taken as the main entry point to your application.
Advertisements. RequireJS can be initialized by passing the main configuration in the HTML template through the data-main attribute. It is used by RequireJS to know which module to load in your application. For instance − <script data-main = "scripts/main" src = "scripts/require.js"></script>
RequireJS is a basic loader, which is used to loads the JavaScript files, it is a framework to manage dependencies between JavaScript files, and in modular programming, all the functionality divides in different modules, so RequireJs is a best tool to assemble different JavaScript files from different modules by which ...
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With