html_minify wraps result with unwanted '<html><head></head><body> ... </body></html>'
See original GitHub issueIssue Description
I’m minifying a fragment of an HTML doc and html_minify prepends with <html><head></head><body>
and appends a </body></html>
, neither of which I want.
For example:
>>> from htmlmin.minify import html_minify
>>> html = 'boo'
>>> html_minify(html)
u'<html><head></head><body>boo</body></html>'
Is there a way to turn this behavior off?
Issue Analytics
- State:
- Created 10 years ago
- Reactions:1
- Comments:17 (6 by maintainers)
Top Results From Across the Web
How Google, Facebook and other websites minify their html?
Google, Facebook and many other sites are minifying their HTML by removing unnecessary white spaces and new lines from the HTML to send...
Read more >Quickstart — htmlmin 0.1 documentation
Quickstart¶. For single invocations, there is the htmlmin.minify method. It takes input html as a string for its first argument and returns minified...
Read more >html-minifier - npm
Minification comparison. How does HTMLMinifier compare to other solutions — HTML Minifier from Will Peavy (1st result in Google search for "html ......
Read more >minify - Rust
extern crate minify; use minify::html::minify; fn main() { let html = r#" <html> <head> </head> <body> </body> <html> "#; let html_minified = minify(html);...
Read more >How to Minify HTML in W3 Total Cache - BoldGrid
This is over a 50% reduction in total file size. Minify (default) should be your first choice for minifying your HTML, because it...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
wat. No it isn’t. Writing a HTML parser is HARD. Do you seriously think creating, let alone maintaining another one is realistic and smart?
Your problem is that html5lib (and BeautifulSoup) were made for the use case of documents. Fragments are not valid HTML documents, so they trigger automatic element insertion. On serialization, you get a complete (valid) HTML5 document. The question is why you are sending HTML fragments as text/html when your response is not a HTML document – just send a different Content-Type and you’ll be fine.
Is there any solution for this ? I am getting same issues . So, it’s clear that it’s not fixed with current available version .