Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rake-pipeline or requirejs

I am about to start a new emberjs project and I cannot decide whether to use requirejs or rake-pipeline.

The ember advice seems to be to use the rake-pipeline.

Anybody any thoughts on either side of the argument?

like image 955
dagda1 Avatar asked Sep 25 '26 14:09

dagda1


1 Answers

If you want to load the dependencies dynamically after page load on an as-and-when-required basis then requirejs is the preferred option.

However if loading all the script when the page loads is not an issue for you (amount of javascript is small, or lot of javascript is required just for the rendering of content) then rails asset pipeline reduces a lot of boilerplate for you because even if you use require js you will eventually have to use r.js compiler to bundle all the dependencies into a single script. Rails does all of this concatanation and minification transparently behind the scenes without you having to do anything at all. Using the rails asset pipeline eases rolling deployment for you because in development scripts are all served as individual files without minification and in production scripts are served as minified and concatenated. This does not require you to run any build script or optimizer upon every change and you don't even have to modify anything in your HTML files. As long as you follow the sprockets specifications and specify the dependencies (which you have to do in case of requirejs too) everything works out of the box.

Also, Rails asset pipeline does not tie your client application to rails platform as sprockets (the dependency manager used behind in the rails pipeline) can be used independently without rails.

If however AMD compatibility is important for you (for example you are planning on using the same code on a NodeJS server as well as client, or are creating a distributable library) then requirejs is a great option.

You can also take a look at https://github.com/jwhitley/requirejs-rails/ which attempts to integrate requirejs into the rails pipeline. Please make sure that you have a reasonable level of familiarity with both requirejs and rails before you adopt this approach.

like image 104
lorefnon Avatar answered Sep 28 '26 02:09

lorefnon