Giter Site home page Giter Site logo

Comments (8)

paolochiodi avatar paolochiodi commented on August 14, 2024

Are you passing any options to htmlcompressor?
My first impression is that you specified an unsupported object as css compressor
(any object that has a compress method is supported)

from htmlcompressor.

marvindanig avatar marvindanig commented on August 14, 2024

I've these options for the htmlcompressor:

 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

This has been working normal all this while, until today. And logs didn't show this error before. Which object do you suspect are unsupported and people could easily include?

from htmlcompressor.

paolochiodi avatar paolochiodi commented on August 14, 2024

Here's the problem: Sass is not supported as a css compressor.
Not even sure it can be used as a compressor.
You could set it to :yui (requires gem yui-compressor) or use something else like cosmic (but may need some additional wrapping)

See here for more infos https://github.com/paolochiodi/htmlcompressor#css-and-javascript-compression

from htmlcompressor.

paolochiodi avatar paolochiodi commented on August 14, 2024

Anyway, chances are that you don't even need css compression in your html files. Do you have lot of <style> tags in them?

from htmlcompressor.

marvindanig avatar marvindanig commented on August 14, 2024

Just one style tag overall or maximum two on a few specific pages. Interesting that the error never popped up on my actual production server so far. What is Cosmic? Sounds like an interesting name.

Hmm, so the compression of CSS need not be specified 'coz rails is doing it anyway. Let me see if it can be done away with. Thanks Paolo 👍

from htmlcompressor.

paolochiodi avatar paolochiodi commented on August 14, 2024

The css compression options is to enable compression of css inside <style> directly in your html pages.
External stylesheets linked with the <link> are already handled by Rails and Sass.

You probably never seen it in production because you don't have a <style> tag in your pages?

If you need it, check the yui-compressor gem: it will require java to be installed but it's the best option.

from htmlcompressor.

paolochiodi avatar paolochiodi commented on August 14, 2024

Cosmic = ccsmin, damn corrector...

from htmlcompressor.

marvindanig avatar marvindanig commented on August 14, 2024

👍

from htmlcompressor.

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.