Working on a very large site with a ton of js/jQuery all in a tangled spaghetti mess.
I want to start writing new code (to start) in a more structured way. I’ve been looking at various sites online about the Prototype pattern, the Module pattern, as well as AMD, CommonJS etc. and I’m not sure what the factors in my decision on which to use should be.. and then what is necessary to get it running (simple as just including the file?)
I don’t want to be reliant on jquery, but I do want to be able to easily use jquery and other things from the rest of the site. We aren’t using any loaders or anything, but would like to.
I’m really not sure what exactly is required for me to decide to add some functionality to the site using some of these patterns
I like requirejs, which is an AMD implementation. It is nicely designed for use as a loader, and there are specific instructions for using it with jQuery (and jQuery plugins).
However, it works best as a “all-or-nothing” approach. Mixing with existing, globals-heavy code is difficult. You can use “shim” configurations, which “imports” global variables into module-like wrappers, but I’ve always found it problematic. And I have yet to use it for an exceedingly complex site.
Viewing 2 posts - 1 through 2 (of 2 total)