[ANN] MergeJS - Easily merge, compress, cache, and version y

After reading Cal Henderson’s article on Vitamin Serving Javascript
Fasthttp://synthesis.sbecker.net/articles/2006/06/03/www.thinkvitamin.com/features/webapps/serving-javascript-fastI
was immediately inspired to create a plugin to easily facilitate this
in
Ruby on Rails. I whipped up most of it right then, and finally got
around to
polishing it for release today.

Told myself I wasn’t allowed to eat today until I finished. How’s that
for
inspiration?

Here you go!

MergeJS:http://synthesis.sbecker.net/pages/merge_js

Thanks!

The page seems not to respond. Hope you are o.k. (with or without eating
yet
…)

Welp, Dreamhost happened to come under a DoS attack right after I
announced it: http://www.dreamhoststatus.com/2006/06/03/more-outages/

How awesome is that? It’s real, I swear! Just check back soon! :slight_smile:

And don’t worry about me. I ate. haha…

  • Scott

On 6/3/06, Roberto S. [email protected] wrote:

was immediately inspired to create a plugin to easily facilitate this in



Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Scott B.
Web D.
Electro Interactive, Inc.
Office: 813-333-5508

Scott B. wrote:

Welp, Dreamhost happened to come under a DoS attack right after I
announced it: http://www.dreamhoststatus.com/2006/06/03/more-outages/

How awesome is that? It’s real, I swear! Just check back soon! :slight_smile:

And don’t worry about me. I ate. haha…

  • Scott

On 6/3/06, Roberto S. [email protected] wrote:

was immediately inspired to create a plugin to easily facilitate this in

Not bad. This plugin definately shows promise but a few things would
need improving before I wouls stick it in my app.

I think you should be able to define the js file names as symbols,
rather than strings. When I tried to use symbols the tag was
not even output to the header. I would add:

sources.collect!(&:to_s)

to the top of your helper method.

Also you should be able to say

<%= javascript_include_merged :defaults %>

just like you can say

<%= javascript_include_tag :defaults %>

Lastly, I don’t like that you have to manually generate the resulting js
file. I think it should compile it on the fly and then cache it
somehow, like action cacheing. I can easily see forgetting to run the
rake task and then beating my head against the desk because the new
javascript works in development but not production.

Symbols and :defaults are now supported, along with a bunch of other
little enhancements.

http://synthesis.sbecker.net/pages/merge_js

Thanks!

Scott B.
Web D.
Electro Interactive, Inc.

On 4-jun-2006, at 19:16, Scott B. wrote:

I like the idea of allowing the use of symbols and using :defaults for
the rails default js files. I will be adding those soon! :slight_smile:

The idea of the rake task is to process this only once, at the time of
deployment. If you add it to your capistrano deployment script, thats
the last time you’ll ever have to think about it. This is the best way
for performance. Having dealt with SLOW shared hosting environments,
I’m pretty adverse to adding any unnecessary processing that has to
happen on each request.

Put the JS rebuild into the environment.rb, it will be run when the
app is starting. After getting going with Rails I tend to look with
great suspicion at all the “build, rebuild, recompile and remerge and
then archive and compact and THEN it will run” type operations.


Julian ‘Julik’ Tarkhanov
please send all personal mail to
me at julik.nl

I like the idea of allowing the use of symbols and using :defaults for
the rails default js files. I will be adding those soon! :slight_smile:

The idea of the rake task is to process this only once, at the time of
deployment. If you add it to your capistrano deployment script, thats
the last time you’ll ever have to think about it. This is the best way
for performance. Having dealt with SLOW shared hosting environments,
I’m pretty adverse to adding any unnecessary processing that has to
happen on each request.


Scott B.
Web D.
Electro Interactive, Inc.

Could this be done for CSS files too. Maybe have the plugin do both.

Well, having dealt with Dreamhost (el slowio), the biggest performance
hit is on the first request - and they kill off your .fcgi processes
fairly often, so you have to endure that yet again. I personally hate
it when plugins tack on more stuff to the startup process. The more
javascript files you have to compress, the longer your startup will
become. BUT, I guess I’ll see about adding this option for those that
want it. Using Capistrano makes the rake task option a peice of cake,
so thats what I prefer.


Scott B.
Web D.
Electro Interactive, Inc.

Scott Fortmann-Roe wrote:

Could this be done for CSS files too. Maybe have the plugin do both.

Yep, in the Plan. :slight_smile:


Scott B.
Web D.
Electro Interactive, Inc.