html-minifier icon indicating copy to clipboard operation
html-minifier copied to clipboard

"Collapse inline tag whitespace" doesn't work between <img> elements

Open alexschcom opened this issue 4 years ago • 1 comments

When I do:

<div>
    <span></span>
    <span></span>
</div>

it minifies correctly to <div><span></span><span></span></div> (without a space between the two <span>s).

However, when I replace the <span>s with <img>s:

<div>
    <img>
    <img>
</div>

it minifies with a space in between: <div><img> <img></div>


Configuration:

{
    collapseWhitespace: true,
    collapseInlineTagWhitespace: true,
    conservativeCollapse: false,
    ...
}

alexschcom avatar Feb 14 '22 15:02 alexschcom

Actually, the first output (for span) seems incorrect?

But when testing both, e.g.

<!doctype html>
<title>Test</title>
<div>
  <span></span>
  <span></span>
</div>
<div>
  <img src=foo alt>
  <img src=foo alt>
</div>

the outcome seem correct for both cases even with the default settings (except with “Remove tag whitespace” off) of html-minifier (and also of HTML Minifier Next):

<!doctype html><title>Test</title><div><span></span> <span></span></div><div><img alt src=foo> <img alt src=foo></div>

Would also speak for HTML Minifier Next but happy to look into any issues there!

j9t avatar Sep 20 '25 11:09 j9t