I'm generating some js output for each user using a template named example.js.erb
. This is basically a javascript file where I have to put in the user's unique details. I'm using this inside of a widget for the user.
Is there any way to minify the js as it's being rendered? Right now the javascript is being rendered correctly, but it's in it's long form and I'd like to minify the output in order to reduce file size and increase download speed.
Rails Javascript compression/minification on respond_to javascript response?
respond_to do |format|
format.js { self.response_body = minify(render_to_string) }
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With