-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collapse whitespace? #29
Comments
Interesting. Looks like the grunt plugin uses html-minifier. Would you be able to work on this? |
Hi yea I'm working on this. Also what's the deal with all the '\n' the to_json method makes. We don't need that. I'm looking over the documentation and I'm assuming it uses the At least escape_javascript does. http://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html |
Ok I did something like this. Not sure if it's correct but it seems to be working. Not passing tests right now though. https://github.com/drewhjava/angular-rails-templates EDIT Ok, I ran this on my application and it only dropped the total file size 30kb. Went from 850kb to 820(239kb gzip) Haha. Still think it's worth it though. EDIT: Be careful when updating if you test this because it updates sprockets(cause it's not locked) and there is an issue with sprockets and SASS I ran into. |
I like the idea. It's kind of a bummer that you're using an 0.0.7 release of a html compressor, seeing as this project is also in early development. I haven't looked around, and I don't know what, if anything, is better. About data.to_json.chop! # I'd guess this would be most efficient
data.to_json.chomp!
data.to_json.rstrip!
data.to_json[0...-1] I don't know if any these have performance consequences for long strings, but I definitely prefer using them over monkey-patching |
@drewhjava I've been working on a lot of enhancements to this gem, one of which is support for HtmlCompressor, inspired by your work. I'd appreciate it if you could give it a spin. https://github.com/whitehat101/angular-rails-templates I did introduce some non-backwards compatible changes to the gem. I think I mentioned them all in my readme, but here is a quick version: #Gemfile
gem 'htmlcompressor'
gem 'angular-rails-templates', github: 'whitehat101/angular-rails-templates'
# config/application.rb
config.angular_templates.htmlcompressor = {remove_intertag_spaces: true}
# config/environments/development.rb
# add this, restart the webserver, and any change you make to this string will rebuild all your assets
config.assets.version = '1.1'
# app/assets/javascripts/application.js
//= require angular-rails-templates # before you require templates All assets now need to have
|
thanks both @whitehat101 and @drewhjava ! 0.1.0 has the HTML compressor. |
Can you add a flag to collapse whitespace, I have a large project and I compiled the templates using the Grunt angular plugin just to see and it reduces file size significantly. It seems they are running an html minifier and it's collapsing the whitespace. Thanks!
The text was updated successfully, but these errors were encountered: