I am building a single page web application and one the requirements are jQuery, jQuery-ui and any jquery plugins I decide to use during development.
I am also looking into RequireJS and Backbone to form the MVC structure of the application.
While I have no doubt that RequireJS will be very useful in loading the Backbone MVC modules I create, I am some what indifferent to using it to load jQuery and its plugins.
This is because I consider jQuery to acceptable to use in the global namespace as it will be used everywhere in the entire application.
So my question is: is it okay to make such a separation between modular components and what I would consider as a necessary global component jQuery?
You want something like this:
In your case, you’d replace the jquery-mobile stuff with jquery-ui stuff. Same idea. Jquery is smart enough to put itself in the global namespace, the rest, depending on your version, are not (generally speaking). Hopefully this helps you out. Just remember, if you use a library that isn’t amd compatible, you’ll want to throw it in a shim, like what you see above. The shim is a shortcut to wrapping the library manually (aka, yourself).