paolochiodi / htmlcompressor

A work in progress port of google's htmlcompressor.jar
Other
150 stars 26 forks source link

HTML not minified on heroku #10

Closed cheeyeo closed 10 years ago

cheeyeo commented 11 years ago

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

paolochiodi commented 11 years ago

Hi, thank you for the kind words.

Can you share more details about your app? Is it a Rails or a rack app? If you can share the snippet of code where you set up the middleware and / or a link to your app I can help with the debug.

In the meanwhile please consider that minification is triggered by two conditions:

Hope this help.

cheeyeo commented 11 years ago

Hi

its a Rails 3.2 app and the middleware is setup within config/production.rb as follows:

options = {
    :enabled => true,
    :remove_multi_spaces => true,
    :remove_comments => true,
    :remove_intertag_spaces => true,
    :remove_quotes => false,
    :compress_css => true,
    :compress_javascript => true,
    :simple_doctype => false,
    :remove_script_attributes => false,
    :remove_style_attributes => false,
    :remove_link_attributes => false,
    :remove_form_attributes => false,
    :remove_input_attributes => false,
    :remove_javascript_protocol => false,
    :remove_http_protocol => false,
    :remove_https_protocol => false,
    :preserve_line_breaks => false,
    :simple_boolean_attributes => false
  }

  config.middleware.use HtmlCompressor::Rack, options
paolochiodi commented 11 years ago

Hi, during the week end I created a testing app using rails 3.2 and ruby 1.9.3 and setup htmlcompressor with your same settings and everything is working properly for me.

Can you please share some more detail of your app? Maybe a link to the production app?

cheeyeo commented 11 years ago

Hi Paolo

the link to the production app is at friendsofthekingspark-glasgow.co.uk

the middleware is switched on but when you go to gtmetrix for example it keeps saying html is not compressed?

I'm wondering if the order of the middleware is important as the site is hosted on heroku and Rack::Deflate is before the htmlcompressor middlware?

thanks

paolochiodi commented 11 years ago

Hi, the html of your site is actually minified (as you can see from the html source of the page). I ran a performance test on GTMetrix and the "Page Speed" report is telling that the html can be further minified (it is also offering an example of what can be obtained with higher compression)

To achieve that you may want to turn on some additional optimization in htmlcompressor. You should be able to match gtmetrix compression with this set of options:

options = {
    :enabled => true,
    :remove_multi_spaces => true,
    :remove_comments => true,
    :remove_intertag_spaces => true,
    :remove_quotes => true,
    :compress_css => true,
    :compress_javascript => true,
    :simple_doctype => false,
    :remove_script_attributes => true,
    :remove_style_attributes => true,
    :remove_link_attributes => false,
    :remove_form_attributes => false,
    :remove_input_attributes => false,
    :remove_javascript_protocol => false,
    :remove_http_protocol => true,
    :remove_https_protocol => true,
    :preserve_line_breaks => false,
    :simple_boolean_attributes => true
}

Please let me know if this set of options works for you, otherwise I'll be happy to help finding the combination that better suits you.

Paolo ps: here the link for the gtmetrix report: http://gtmetrix.com/reports/friendsofthekingspark-glasgow.co.uk/6wGaPw1S

cheeyeo commented 11 years ago

Hi Paolo

thanks for taking the time to check it out for me on gtmetrix

I will try your config today and see if it improves it. I normally check the developer tools console and forgot to check the source itself! thanks for pointing that out and also the meaning of the gtmetrix report

paolochiodi commented 10 years ago

Hi @cheeyeo can I consider this issue closed?