Code Monkey home page Code Monkey logo

Comments (5)

kgryte avatar kgryte commented on May 20, 2024

Related issue: kangax/html-minifier#1092.

from html-minifier-terser.

DanielRuf avatar DanielRuf commented on May 20, 2024

Since this is documented, can be tested on https://terser.org/html-minifier-terser/ and there is also a way to prevent all optimizations (https://github.com/terser/html-minifier-terser#ignoring-chunks-of-markup) I'm closing this issue.

There are good reasons why all optimizations are disabled by default and why this is in red:
Bildschirmfoto 2021-09-14 um 00 18 27

Option Description Default
removeEmptyElements Remove all elements with empty contents false

from html-minifier-terser.

kgryte avatar kgryte commented on May 20, 2024

Ignoring chunks of markup is fine, so long as you are authoring the HTML in question. Otherwise, one needs to dynamically modify the received markup in order to preserve empty elements in SVG.

from html-minifier-terser.

DanielRuf avatar DanielRuf commented on May 20, 2024

True. Normally this is done in webpack setups with the right plugins which replace texts or before compilation using sed or other solutions.

In general this case is currently not covered by the tests as it is not recommended to enable removeEmptyElements since this can break and will break things.

So far only html elements are not affected by this:

https://github.com/terser/html-minifier-terser/blob/v6.0.2/src/htmlminifier.js#L429
https://github.com/terser/html-minifier-terser/blob/v6.0.2/src/htmlminifier.js#L1134
https://github.com/terser/html-minifier-terser/blob/v6.0.2/src/htmlminifier.js#L517-L545

I'm not sure if it makes sense to add svg and xml elements to this function by default but this could lead to the case, that we will have to add many more tags to this function to prevent such issues and that this has to be correctly tested.

But as this is marked as red / breaking, I'm opting for keeping as it is and removing the option from the CLI like you already did.

If this is not in your interest, you may want to check https://github.com/tdewolff/minify#html

https://go.tacodewolff.nl/minify

from html-minifier-terser.

kgryte avatar kgryte commented on May 20, 2024

Thanks for the details and links. :)

from html-minifier-terser.

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.