Domanda

Is there a tool or require.js function I can use to determine the fetching and loading order of my modules/traditional scripts?

For example,

a.js:

define(['b', 'c'], function(b,c){});

b.js:

define(['d'], function(d){});

and then a main.js that has

require(['a'], function(a){});

My assumption here is that:

  1. a.js will be fetched first
  2. b.js and c.js will be fetched second
  3. d.js will be fetched last

and the modules will be loaded in the order of d -> b -> c -> a. Or perhaps, d and c at the same time (since c has no dependencies like d) then b and finally a.

However, I'm never 100% certain my assumptions are correct. I can refresh the page 100 times and verify I get no error, but I'm still paranoid that the 101st try will break.

AMD module developers, how do you debug this?

È stato utile?

Soluzione

For fine control over the fetching order of modules, there's the order plugin.

You can also open the network console in Chrome/Firebug etc. to see the fetches take place.

But, your example is a fairly straightforward one that should have no problems either in the 101st iteration or the 1001st. I don't see anything to be concerned about or that needs debugging.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top