mtscout6/knockout — comment on commit 39caa75bbcf86ae87bbee129e80e53a008abb270
File:  line 0
By neonstalwart:

i'll tell you what i think to be the best advice. i believe that jquery and underscore could (and should) be anonymous modules. it is much more of a "hazard" to use named modules rather than anonymous modules. the "hazard" being talked about in the quote you referenced is when someone tries to include a module via a script tag rather than by using the loader to load the module. ie this is the hazard:

```html

```

the problem here is that ko.js will detect that `define` exists and will attempt to call `define` to define the ko module. since the loader did not actively initiate the loading of ko.js, it has no way to imply an id for this anonymous module and so loading "without using an AMD loader" is the "hazard". the fix is simple - remove the script tag that loads ko.js and let the loader dynamically/asynchronously load the module only when another module has declared a dependency on it.

for some reason, it was decided that adding ids for a couple of libraries was a better solution than having people avoid loading these modules "without using an AMD loader" even though an AMD loader was explicitly included in their page. as you may have guessed, not everybody sees it the same way.

with ko as an anonymous module, someone using AMD can use ko via whatever id they want. they can also do a build that will add the appropriate id for ko to work when included as part of a layer. it also makes it possible to use 2 versions of ko in an application at the same time. these things are not possible if you hardcode an id. the id should be thought of as an internally private property that is a way for the builder and loader to work together but shouldn't be used apart from that case.

for more details on the debate around this, see the discussion at https://groups.google.com/forum/#!topic/amd-implement/VAtOIIyVrOs which also references:
- http://dvdotsenko.blogspot.com/2011/12/amd-modules-with-named-defines-so-much.html
- http://bdframework.org/bdLoad/docs/bdLoad-tutorial/bdLoad-tutorial.html#nameClashes
- http://livedocs.dojotoolkit.org/loader/amd#the-amd-api

its probably a debate that's more than you might care to dig into but hopefully that's enough information to satisfy your curiosity.