Giter VIP home page Giter VIP logo

htmlcompressor's People

Contributors

andrewkvalheim avatar bhollis avatar bolmaster2 avatar danielcooper avatar georgegorbanev avatar gustavolobo avatar le0pard avatar mc-jordan-andree avatar paolochiodi avatar rmoriz avatar scudelletti avatar strcmp avatar whitehat101 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

htmlcompressor's Issues

The simple_boolean_attributes strips non-boolean attributes

Hi there.

I just noticed in an app that is using AngularJS, that middleman-minify-html (which relies on the htmlcompressor gem) strips some values:

  • ng-disabled="compareDisabled" is transformed to ng-disabled
  • also data-ng-disabled="compareDisabled" is transformed to data-ng-disabled

Seems to me that the simple_boolean_attributes option, when activated, strips this valid e.g. non-boolean attributes.
Maybe the BOOLEAN_ATTR_PATTERN is mismatching?

PS: Same applies probably to ng-selected, ng-checked and ng-readonly.

Cached Pages don't get compressed

I am using actionpack-page_caching to cache static pages and the htmlcompressor as middleware. When I look at my Rails server's response source code in Chrome DevTools it is compressed but when I look at the source of my Page Cached file it is not compressed.

How would this best be fixed? Thanks.

Gem is slowing down the server by 3 seconds or so.

Folks,
I've used this Gem for around 6 months, and just discovered that it added ~3 seconds to the response time of my server. This is really bad. Please see this as a warning - if you think to try it - make sure you measure your overall response time of the server (whether if it's apache or else). I removed it completely and now the website is really fast.

The right solution should be else. Either doing the compression in a low level language, to add speed, or, better, doing the compression not in real-time. Something like assets pipeline for the views and partials.

Warnings with Ruby 2.2.0

Hi paolochiodi,

thanks for your gem.

There are new warnings with ruby 2.2.0:

/Users/dmasur/.rvm/gems/ruby-2.2.0/gems/htmlcompressor-0.1.2/lib/htmlcompressor/compressor.rb:112: warning: duplicated key at line 132 ignored: :javascript_compressor
/Users/dmasur/.rvm/gems/ruby-2.2.0/gems/htmlcompressor-0.1.2/lib/htmlcompressor/compressor.rb:113: warning: duplicated key at line 133 ignored: :css_compressor

the warnings is pretty clear. you declared this twice. I don't know why, maybe for documentation, so i didn't open a pull request.

Can you take a look at it?

Properly remove the whitespace around <li> tags

  • tags leave one space before and after the
  • tag that results in classic html whitespace issue.
    <ul> <li>Total Shares</li> <li> Other li tag </li> </ul>

    seems like all the tags have a leading and trailing space.

  • With this config my site slow down a bit. You can say me why?

    Hi guys,

    If I use this config my site slow down a bit. You can say me why?

    I followed this guide: https://remino.net/rails-html-css-js-gzip-compression/

    # config/initializers/compression.rb
    
    Rails.application.configure do
      # Use environment names or environment variables:
      # break unless Rails.env.production? 
      break unless ENV['ENABLE_COMPRESSION'] == '1'
    
      # Strip all comments from JavaScript files, even copyright notices.
      # By doing so, you are legally required to acknowledge
      # the use of the software somewhere in your Web site or app:
      uglifier = Uglifier.new output: { comments: :none }
    
      # To keep all comments instead or only keep copyright notices (the default):
      # uglifier = Uglifier.new output: { comments: :all }
      # uglifier = Uglifier.new output: { comments: :copyright }
    
      config.assets.compile = true
      config.assets.debug = false
    
      config.assets.js_compressor = uglifier
      config.assets.css_compressor = :sass
    
      config.middleware.use Rack::Deflater
      config.middleware.insert_before ActionDispatch::Static, Rack::Deflater
    
      config.middleware.use HtmlCompressor::Rack,
        compress_css: true,
        compress_javascript: true,
        css_compressor: Sass,
        enabled: true,
        javascript_compressor: uglifier,
        preserve_line_breaks: false,
        remove_comments: true,
        remove_form_attributes: false,
        remove_http_protocol: false,
        remove_https_protocol: false,
        remove_input_attributes: true,
        remove_intertag_spaces: false,
        remove_javascript_protocol: true,
        remove_link_attributes: true,
        remove_multi_spaces: true,
        remove_quotes: true,
        remove_script_attributes: true,
        remove_style_attributes: true,
        simple_boolean_attributes: true,
        simple_doctype: false
    end

    compressing js templates

    Is there a way to compress .jst.eco files with this gem automatically? I've been using the gem happily for .html.erb files but js templates cause HTML whitespace issue for inline-block elements.

    No CSS Compressor. Please set the :css_compressor option

    My settings are as follows

    require 'htmlcompressor'
    Rails.application.configure do
    
      # Strip all comments from JavaScript files, even copyright notices.
      # By doing so, you are legally required to acknowledge
      # the use of the software somewhere in your Web site or app:
      uglifier = Uglifier.new output: { comments: :none }
    
      # To keep all comments instead or only keep copyright notices (the default):
      # uglifier = Uglifier.new output: { comments: :all }
      uglifier = Uglifier.new output: { comments: :copyright }
    
      config.assets.compile = true
      config.assets.debug = false
    
      config.assets.js_compressor = uglifier
      config.assets.css_compressor = :sass
    
      config.middleware.use Rack::Deflater
      config.middleware.insert_before ActionDispatch::Static, Rack::Deflater
    
      config.middleware.use HtmlCompressor::Rack,
        compress_css: true,
        css_compressor: :sass,
        compress_javascript: true,
        javascript_compressor: uglifier,
        preserve_line_breaks: false,
        remove_comments: true,
        remove_form_attributes: false,
        remove_http_protocol: false,
        remove_https_protocol: false,
        remove_input_attributes: true,
        remove_intertag_spaces: false,
        remove_javascript_protocol: true,
        remove_link_attributes: true,
        remove_multi_spaces: true,
        remove_quotes: true,
        remove_script_attributes: true,
        remove_style_attributes: true,
        simple_boolean_attributes: true,
        simple_doctype: false
    end
    
    

    But I am getting the following error No CSS Compressor. Please set the :css_compressor option

    Problems with remove_spaces_inside_tags()

    In current version, remove_spaces_inside_tags() is always called and cannot be disabled by option.

    And this compression causes corruption in <input> value.

    <!-- before -->
    <input value=" value = 5 ">
    
    <!-- after -->
    <input value=" value=5 ">

    So. at least either of following improvements is necessary:

    1. Create option to disable this compression
    2. Exclude attribute values from this compression

    :simple_boolean_attributes and ng-disabled

    When :simple_boolean_attributes is set to true, ng-disabled attribute would be screwed up. For example, consider this code:

    <button ng-disabled="bar()">Foo</button>

    After compression, it becomes:

    <button ng-disabled"bar()">Foo</button>

    Thanks.

    Doesn't work together with Rack::Deflater

    When I use in config both HtmlCompressor and Rack::Deflater - I get data stream error:

    config.middleware.use HtmlCompressor::Rack
    config.middleware.use Rack::Deflater
    

    YUI compressor version outdated

    Project depends on YUI version 0.9.6 (technically on any version that is >= 0.9.6 and <0.9.7 ;)). 0.9.6 is three years old and is broken on Windows platform due to popen4 dependency.

    Please consider upgrading

    NoMethodError (undefined method `compress' for Sass:Module):

    I'm getting the following error only on production mode:

    Completed 500 Internal Server Error in 15ms (Views: 0.6ms | ActiveRecord: 2.3ms)
    F, [2015-02-02T10:21:13.342194 #17722] FATAL -- :
    NoMethodError (undefined method compress' for Sass:Module): htmlcompressor (0.1.2) lib/htmlcompressor/compressor.rb:555:incompress_css_styles'
    htmlcompressor (0.1.2) lib/htmlcompressor/compressor.rb:495:in block in process_style_blocks' htmlcompressor (0.1.2) lib/htmlcompressor/compressor.rb:494:inmap!'
    htmlcompressor (0.1.2) lib/htmlcompressor/compressor.rb:494:in process_style_blocks' htmlcompressor (0.1.2) lib/htmlcompressor/compressor.rb:476:inprocess_preserved_blocks'
    htmlcompressor (0.1.2) lib/htmlcompressor/compressor.rb:202:in compress' htmlcompressor (0.1.2) lib/htmlcompressor/rack.rb:45:incall'

    Didn't see this been reported before, but is no one else seeing it?

    regexp has invalid interval and '}' without escape

    I'm using {:awestruct} and get the following warnings:

    /var/lib/gems/1.8/gems/htmlcompressor-0.0.5/lib/htmlcompressor/compressor.rb:80: warning: regexp has invalid interval
    /var/lib/gems/1.8/gems/htmlcompressor-0.0.5/lib/htmlcompressor/compressor.rb:80: warning: regexp has }' without escape /var/lib/gems/1.8/gems/htmlcompressor-0.0.5/lib/htmlcompressor/compressor.rb:80: warning: regexp has invalid interval /var/lib/gems/1.8/gems/htmlcompressor-0.0.5/lib/htmlcompressor/compressor.rb:80: warning: regexp has}' without escape

    Line at fault in compressor.rb:

    LINE_BREAK_PATTERN = Regexp.new("(?:\p{Blank}(\r?\n)\p{Blank})+")

    Escaping the curly brackets certainly removes the warning but I'm not 100% if that's the correct thing to do.

    Cheers,
    Scott.

    HTML not minified on heroku

    Hi

    firstly thanks for the great work and i have used your gem in a production app on heroku

    I set it up as per your instructions however when I ran the metrics code under page speed it keeps coming up with the html is not minified?

    is there any setting i need to use while adding the middleware? thanks for your help

    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.