After having investigated several script loaders I decided to go back to linking all script files manually in HTML as it's the most reliable and straightforward solution.
There are many script loaders out there to choose from, most of which are not only in development, but used by their authors in separate projects, so are likely to accept bug reports, especially if their most basic functionality or portability are concerned. That is the main reason for selecting such a module loader over a home-brew solution!-) Personally, I'd suggest to switch from script loading to module loading as soon as possible (before you build much code on top). Just wrapping each script in a function gives you control over evaluation order (independent from script loading order) as well as namespace control. Import/export control can be built on top of that. I tried to elaborate on my view of the why and how of module loading, including how to refactor explicit script loading projects into projects using implicit module loading in a blog post a while ago (including code): http://libraryinstitute.wordpress.com/2010/12/01/loading-javascript-modules/ Since others have mentioned script concatenation: you can use the same dependency-resolution and module loading code to build a concatenated file of scripts, right from Javascript - just use toString() to output the modules and their dependencies instead of instantiating the modules with their dependencies. If you output the modules in dependency order, and load such packaged modules first, all dependencies will already be available when the module loader starts looking for them, so no additional requests (the file of modules can then be minified and gzipped - it is just a Javascript file). Claus -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
