Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Javascript compression/minification on respond_to javascript response?

Greetings Rails and Javascript Gurus!

I have a project where I am returning a large javascript file in a

respond_to do |format|
   format.js
end

block.

I am trying to figure out how I can minify or compress the .js response since the .js.erb view is full of comments and varies in size based on the results from the controller.

Anyone have any ideas?

like image 261
Dustin M. Avatar asked Sep 27 '10 16:09

Dustin M.


1 Answers

For Rails 4:

render js: Uglifier.new.compile(render_to_string)
like image 197
Sidhannowe Avatar answered Sep 17 '22 21:09

Sidhannowe