Note that there are some explanatory texts on larger screens.

plurals
  1. POrequirejs , multipage , weird order of execution
    text
    copied!<p>I am using requirejs for a multipage application. I am having a weird issue with the order of execution of the main files. Here is my setup.</p> <p>In all of my html pages ( This main has all the common js files that are required by all my pages) </p> <p>then on each page (say page1.html):</p> <pre><code>&lt;script data-main="main" src="require.js" /&gt; &lt;script&gt; require(['require','main'],function(require) { require(['main-library']); }); &lt;/script&gt; </code></pre> <p>My main.js looks like:</p> <pre><code>require.config({ paths:{ 'lib':'../lib', 'jquery': '../lib/jquery/jquery-1.7.1.min', 'jquery.iframe-transport' : '../lib/jquery.iframe-transport.min.js' }, deps:['jquery','jquery-ui'], shim: { &lt;other shim files&gt; }, }); require([&lt;list of all other dependencies&gt;], function() { }); </code></pre> <p>And the main-library.js looks like:</p> <pre><code>define('main-library', ['main', 'jquery.iframe-transport', &lt;other dependencies&gt; ], function() { } ); </code></pre> <p>My expectation: Was that the "main-library" will not start to load until the "main" and all the dependencies specified in the main are not loaded. I expect this since I require "main-library" in a nested require call on each page. see above. </p> <p>The issue: When my page1.html loads, it looks like the main-library.js starts loading even before the main.js has finished loading and main-library fails to get the require.config and hence the paths for the dependencies are not seen by it. </p> <p>What am I doing wrong ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload