Coder Social home page Coder Social logo

HTML minification is imperfect about inliner HOT 6 OPEN

remy avatar remy commented on July 30, 2024 2
HTML minification is imperfect

from inliner.

Comments (6)

remy avatar remy commented on July 30, 2024 4

Folks, remember, if you want this feature, either use the native 👍 or include a real test or use case, or even better: a PR.

I've not personally hit this issue at all, so I've no real motivation to work on it myself (that's not to say others aren't hitting the issue).

I'm generally deleting github issues with just +1 in them these days.

from inliner.

remy avatar remy commented on July 30, 2024 3

I like the approach of making the inliner do as much of the leg work for you (allowing you to opt out when it makes sense), so I think it makes sense to use the html-minifier as a module to compress the output.

My only slight concern is aggressive compression on HTML can result on a different visual representation of the markup (ie. I'd want to use the conservativeCollapse flag for instance to ensure spaces remained intact).

I'd be open to a PR if you wanted a shot at it (please check out the contributing doc as it helps with tests and commits).

from inliner.

hsablonniere avatar hsablonniere commented on July 30, 2024 3

👍 for html-minifier with "conservative"/non-agressive options 😄

from inliner.

denis-sokolov avatar denis-sokolov commented on July 30, 2024

I like the approach of making the inliner do as much of the leg work for you (allowing you to opt out when it makes sense), so I think it makes sense to use the html-minifier as a module to compress the output.

Sure! Some projects at some point choose to spin-off a module (say, inliner-lib) that only contains the minimum core logic and make the primary module depend on that and wrap it with more extra functionality. I suggest to keep this possibility in mind if you notice at some point such a need.

My only slight concern is aggressive compression on HTML can result on a different visual representation of the markup (ie. I'd want to use the conservativeCollapse flag for instance to ensure spaces remained intact).

Well, yes. The point is, your current compression on HTML already results in a different visual representation of the markup. As I mentioned in the original issue, for example, you change the visual representation of a placeholder attribute for a textarea, a visual representation for ~~s~~ and others.
Minifying html is pretty hard to do for a general case. In particular, any element may have a white-space: pre specified in CSS. Thus it's important to allow disabling and possibly customize the minification process. If you keep HTML minification as part of the module, I'd suggest exposing the ability to pass options to html minifier.

I can't make any promises about PRs though, but maybe.

from inliner.

marcelboettcher avatar marcelboettcher commented on July 30, 2024

+1

from inliner.

sinedied avatar sinedied commented on July 30, 2024

I also have the issue when I include JS minified code: when the collapseWhitespace option is enabled, it breaks the JS code. The html minification should really be done by a separate proven package, such as htmlmin for example.

It would also be nice if the minifier options for html/css/js could be further customized by passing through arguments directly to the minifier (I also have issues with uglifyjs default options, and there's no way to override them). This way everyone should be happy 😁

from inliner.

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.