Code Monkey home page Code Monkey logo

Comments (6)

pitr avatar pitr commented on June 22, 2024

Interesting. Looks like the grunt plugin uses html-minifier. Would you be able to work on this?

from angular-rails-templates.

drewhamlett avatar drewhamlett commented on June 22, 2024

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
JS_ESCAPE_MAP.

At least escape_javascript does.

http://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html

from angular-rails-templates.

drewhamlett avatar drewhamlett commented on June 22, 2024

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:
Ok the size savings maybe a lot bigger then this. It seems sprockets is still caching the templates that have not changed when I deploy to Heroku. Need to figure out how to change this.

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.

activeadmin/activeadmin#3005

from angular-rails-templates.

whitehat101 avatar whitehat101 commented on June 22, 2024

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 \n, instead of re-implementing escaping. Why not use a standard tool:

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 String.

from angular-rails-templates.

whitehat101 avatar whitehat101 commented on June 22, 2024

@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 .html in their name. .nghaml and .ngslim aren't supported.

index.html
foo.html.haml
bar.html.slim

from angular-rails-templates.

pitr avatar pitr commented on June 22, 2024

thanks both @whitehat101 and @drewhjava ! 0.1.0 has the HTML compressor.

from angular-rails-templates.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.