An Interest In:
Web News this Week
- March 27, 2024
- March 26, 2024
- March 25, 2024
- March 24, 2024
- March 23, 2024
- March 22, 2024
- March 21, 2024
A RequireJS, Backbone, and Bower Starter Template
Switching to a modular approach to writing JavaScript is unfortunately a more difficult process than we might hope. Once you understand the concept of AMD, you then have to figure out the logistics: how do you setup RequireJS? What about non-AMD libraries? What about dependency management? What about configuration and optimization?
Download the Video
Using This Starter Template
The repo for the video tutorial should give you an excellent starting point, when beginning new RequireJS + Backbone projects. Once you’re comfortable with the process, also, at some point, be sure to consider Yeoman with RequireJS support.
Quick Setup
First, of course, download this repo. Then, from the Terminal (assuming Node.js installed), install RequireJS.
npm install requirejs
Next, we need an easy way to deal with dependency management. We’ll use Bower, from the guys at Twitter.
npm install bower
Let’s now install the dependencies for this project. I’m assuming that we’re building a Backbone project, so I’ve listed RequireJS, jQuery, Underscore, and Backbone as dependencies.
bower install
Please note that we’re using the AMD versions of both Backbone and Underscore to make the setup process as easy as possible.
When ready to build the project, run:
build/build.sh
this will create a new `dist` directory, copy the files over, run the r.js
optimizer on assets, and clean it the file structure a bit for production. Refer to app.build.js
for configuration options.
CSS Imports
If you’re not using a preprocessor, feel free to modularize your stylesheets, and @import
them into a master stylesheet. During the build process, r.js
will merge these files together, so that you don’t have to worry about any performance hits from using @import
.
Original Link: http://feedproxy.google.com/~r/nettuts/~3/XimSIcawE70/
TutsPlus - Code
Tuts+ is a site aimed at web developers and designers offering tutorials and articles on technologies, skills and techniques to improve how you design and build websites.More About this Source Visit TutsPlus - Code