javascript - Using require.js module in node AND browser -
i create (require.js style) amd module can used in browser , in node. best way this? keep seeing references r.js, still not 100% sure on how use it, or if necessary situation.
also, when including module in node, still run require('module-name'), or change well?
first things first: amd basics, what can them, how optimize them
in extremely simple terms
- amd modules reusable js code. think of them functions kept in separate files.
- amd loaders central functions call other functions (modules). think of them "main" method in c or java.
- requirejs framework pulls scattered code , stitches in usable form.
- requirejs works in browser. result, code "stitched" in web browser.
- r.js works offline (in web server or on development machine) "stitch" code offline when reaches web browser, it's "stitched".
- use of requirejs lib must no matter want "stitch" code in browser or want serve code "pre-stitched".
- use of r.js optional. it's needed if want increase performance , decrease http calls.
Comments
Post a Comment