Comments (6)
Interesting. Looks like the grunt plugin uses html-minifier. Would you be able to work on this?
from angular-rails-templates.
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.
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.
from angular-rails-templates.
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.
@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.
thanks both @whitehat101 and @drewhjava ! 0.1.0 has the HTML compressor.
from angular-rails-templates.
Related Issues (20)
- Uncaught SyntaxError: Unexpected token < HOT 2
- How to specify config if I am using templates inside a mountable engine (namespace isolated) HOT 3
- Extension `.html` should not be necessary anymore HOT 1
- Deprecation warning from sprockets 3.7.0 HOT 6
- Rails functions in .erb templates for angular HOT 1
- Having issues with 'angular-cookie' loading HOT 1
- NoMethodError: undefined method `bytesize' for nil:NilClass HOT 3
- Failed to load template HOT 2
- Docs: templates location
- Does this gem work with Angular 2 and Rails 5? HOT 1
- How to use Devise helper on template? HOT 2
- How to show image in angular template with .html extention HOT 2
- I got empty page in production mode HOT 3
- Rails 5.1 compatibility? HOT 10
- Empty page when deploying to sub-uri
- instance variable
- inline_svg with RAILS_ENV=production HOT 1
- Rails 6 compatibility HOT 4
- Looking for a new maintainer? HOT 1
- Support for Rails 7.1? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-rails-templates.