Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing html closing tag & both body tags.

See original GitHub issue

Hi guys,

When I opened my website with live server I noticed none of my JS functionalities were working. I quickly glanced over the minified HTML file and found that the html closing tag and both body tags were missing in the minified version.

I am running html-minifier with node-minifier

"@node-minify/core": "^4.0.5", "@node-minify/cssnano": "^4.1.0", "@node-minify/html-minifier": "^4.0.5", "@node-minify/uglify-es": "^4.0.5",

All the other minifiers have ran successfully.

I have a simple node-minifier config with no error handling, etc.

const minify = require("@node-minify/core")
const uglifyES = require("@node-minify/uglify-es")
const htmlMinifier = require("@node-minify/html-minifier")

  compressor: cssnano,
  input: "./app/public/index.css",
  output: "index.min.css",
  callback: function(err, min) {}

  compressor: uglifyES,
  input: "./app/public/index.js",
  output: "index.min.js",
  callback: function(err, min) {}

  compressor: htmlMinifier,
  input: "./app/public/index.html",
  output: "index.min.html",
  callback: function(err, min) {}

If this is a node-minifier issue then I will have to address it there. Thanks in advance, and for your hard work folks.


Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

ernestosotelocommented, Apr 26, 2019

@alexlamsl Thanks for your response. I looked into it a bit more, and it seems that Visual Studio Code’s live-server is the culprit. The page works perfectly fine when deployed, or when just opening the page locally without live-server. It seems, for whichever reason, that live-server does not respect opting out of these HTML tags. I definitely wasn’t aware that omitting these tags was permissible for browsers. So, you definitely taught me a thing or two here.

Thanks folks, I will continue to use this package as this was my only minor issue 😃



DamonHDcommented, Jun 27, 2020

Are you using --remove-optional-tags? Does omitting it do what you want?

My core safe set of flags is:

COREOPTS=“–minify-css true --minify-js true
–collapse-whitespace --conservative-collapse
–remove-comments --remove-empty-attributes
–remove-script-type-attributes --remove-style-link-type-attributes

I am a bit more aggressive for ‘lite’ / m-dot pages and also use --remove-optional-tags for them.



On 27 Jun 2020, at 11:07, Qian Chen wrote:

Is there an option to not remove the closing tags. I just want to have the html condensed but I like keep its structure intact.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe

Read more comments on GitHub >

github_iconTop Results From Across the Web

End tag for “body” seen, but there were unclosed elements.
Guide describing the HTML issue detected by the W3C Validator: End tag ... A closing </body> tag has been found, but there are...
Read more >
What happens if we don't add a closing tag? - HTML FAQ
If you do not add a closing tag for an HTML element, you may end up with unexpected issues with your webpage. However,...
Read more >
Get exact html() with closing tag for which starting tag is missing
@adeneo yes I can write the correct HTML while developing an application.But my question is can I detect missing start tags.
Read more >
Optional closing tags in HTML - tempertemper
Finding a missing closing tag that's causing validation issues is much more difficult if there are (perfectly valid) missing closing tags all ...
Read more >
WebD2: Common HTML Tags - University of Washington
An opening tag begins a section of page content, and a closing tag ends it. For example, to markup a section of text...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found