I have been looking into requirejs for couple of days. I think it's a great tool for code structure, modules etc. I'm more interested in performance and lazy loading of modules in production environment. It can minify & merge js and loads modules on demand.
I don't really understand how requirejs achieves this feature(lazy loading of modules in a minified and concatenated file)? I'll appreciate if someone can shed some light on this?
From requirejs:
The optimizer will only combine modules that are specified in arrays of string literals that are passed to top-level require and define calls, or the require('name') string literal calls in a simplified CommonJS wrapping. So, it will not find modules that are loaded via a variable name:
Not sure what above statement means? Can we achieve this lazy loading feature with vanilla JS?
var name='nameofmodule';var module=require(name);
, and that it should be written asvar module=require('nameofmodule');
– Rob W