Opened 13 years ago

Closed 11 years ago

#8646 closed enhancement (fixed)

Make dojo.require() accept multiple resources

Reported by: Dustin Machi Owned by: James Burke
Priority: high Milestone: 1.7
Component: Loader Version: 1.3.0b1
Keywords: Cc:
Blocked By: Blocking:


Discussed this with James today on IM. We would like to modify dojo.require to accept multiple resources in a single statement. This would reduce raw code size (probably not gzipped by much) by reducing the number of dojo.require() statements throughout the codebase. The base implementation will just loop over the individual requires and pull them in as normal. External applications will then have the opportunity to provide alternative package loading mechanisms that can optimize the requests.

Discussed were:

dojo.require("", "foo.baz", true);


dojo.require(["", "foo.baz"], true);

Either solution is acceptable to me, though the first is an api change that could break other things (if someone connects to dojo.require and expects 2 params), but this isn't likely. Using an array will allow the existing api to remain the same, but simply accept an alternative first parameter (an array).

I believe the only other question remaining is how this will affect xdomain loading (or if) by choosing an array over 1..n arguments.

Change History (4)

comment:1 Changed 13 years ago by Eugene Lazutkin

I think the array version is cleaner and more compatible --- it looks like a logical extension of the existing facility for me.

comment:2 Changed 13 years ago by James Burke

As Les pointed out original request was in #7556, but using this ticket to track the changes -- looks like we could get this in without affecting backward compatibility.

However, it may get pushed if there is excessive bloat to support it.

I still favor the dojo.require("", "foo.baz", true) version, it is less to type, and I dislike literal arrays for arguments -- looks aesthetically unpleasing to me and is more to type. Reminds me of the awkwardness of array passing dojo.publish too.

Either syntax will allow for backward compatibility. We'll have to mock up the implementations to see if there is a clear winner in that respect.

comment:3 Changed 13 years ago by James Burke

Milestone: 1.4future

Won't have time for this change for 1.4.

comment:4 Changed 11 years ago by bill

Milestone: future1.7
Resolution: fixed
Status: newclosed

This is basically fixed in 1.7 with the new AMD syntax for loading modules: require(["foo/bar", "foo/baz"], func).

Note: See TracTickets for help on using tickets.