6 ms·
So what's the advantage of requireJS versus browserify? I like browserify because I'm used to the node syntax
by atjoslin 14y ago
So what's the advantage of requireJS versus browserify? I like browserify because I'm used to the node syntax
- stephan83 14y agoIf you use node, I'd stick with browserify. RequireJS is nice if you want to load scripts asynchronously, but in reality your code is usually packed to one or two files so there is no need for the asynchronous part. Plus I dislike the RequireJS syntax, but that's personal taste.
- pfraze 14y agohttp://requirejs.org/docs/node.html http://requirejs.org/docs/node.html I appreciate browserify having the exact same syntax, but RequireJS can do serverside.
- stephan83 14y agoYes but as I said I don't need async loading of scripts, since all my code is packed in usually a single file. Therefore I don't need the RequireJS syntax, and I'd rather stick with a simple require syntax.
- darklajid 14y agoHelp me, I'm still fumbling around in the web world und miss a lot. Why would you even look at require.js if you don't have modular code/code of your own spread over a couple of files? This is for me the one single reason to look into it in the first place. To organize my own code better.
- stephan83 14y agoI do keep my code in separate files. But my servers deliver them in a single file using browserify (https://github.com/substack/node-browserify https://github.com/substack/node-browserify). It's great thing that you use RequireJS to organize your code, and you should keep doing it. We use RequireJS at work and it works pretty well. However my personal preference is browserify, but use whatever works for you.
- firefoxman1 14y agoI've been using the tiny Include.js[1] combined with the standard module pattern. My modules just look like this: (function(exports) { ... exports.moduleName = ...; })(this); Often times you don't need a huge includer just to keep your code modular. [1]http://capmousse.github.com/include.js/ http://capmousse.github.com/include.js/
- mcgwiz 14y agoI haven't used browserify so I may be wrong, but because browserify is not AMD compatible and depends on a build step, the advantage of RequireJS appears to be slightly faster/simpler (or just different) development experience. It looks like with browserify you only ever reference a single script file in your HTML, regardless of development or production environments. While this unifies HTML rendering across development and production environments, during development every time you change a module you must rebuild that script file. In actuality, this is not much of a problem since browserify appears to have a "watch" mode to do this automatically. If you have a huge codebase, building could take a noticeable amount of time. With RequireJS, this build step is not needed during development. When you save module changes and reload your browser (with caching disabled), the changed module will be delivered. If you have a huge codebase, no time-consuming build step is required. Of course in production you want to deliver only a single file, and RequireJS can be used to build this. However, depending on your overall build, you may need to conditionally render different script tags for production and development, which is a tiny but not insignificant bit of complexity. To allow RequireJS to load node (CommonJS-based) modules the module needs to be wrapped in a special function call. RequireJS supplies tooling to help with this. Alternatively, RequireJS can be used in node to load AMD modules, to allow modules to be used client- and server-side. If you have a small codebase and use the same modules in node and in the browser, browserify seems to be the way to go. For large codebases, browserify is only an option if you have lots of modules being used in node and in the browser and find RequireJS' tooling inadequate. Otherwise, RequireJS' flexibility seems to make it the preference.
- combataircraft 14y agoConsider OneJS here; http://github.com/azer/onejs http://github.com/azer/onejs see my comment above for details about the differences; http://news.ycombinator.com/item?id=3915403 http://news.ycombinator.com/item?id=3915403