After playing with AMD / RequireJS, I was wondering if it's worth loading the user interface modules, including templates and CSS, so they are completely independent of the web page.
Sounds good, but I have not seen how it is implemented in the wild, so there may be pitfalls.
Think of some UI module with the following structure:
myWidget |--img |--main.js |--styles.css +--template.tpl
All materials in one folder. It looks very good.
The module in main.js will look something like this:
define(["TemplateEngine", "text!myWidget/template.tpl"], function(TemplateEngine, template) {
Now questions:
- Did I miss something?
- Are there any plugins / concepts on how to achieve this in a βstandardβ way?
- Can the RequireJS optimizer handle the CSS part here, say concat / minify stylesheets, as is done with the JS parts?
- Any opinions on this? Good or bad?
javascript css requirejs js-amd
fbrandel Oct 27 '11 at 2:41 2011-10-27 14:41
source share