I was wondering if there is a way to compress generated html markup, including style tags and more.
I tried with .trim()
but that doesn't seem to remove any spaces. And using trim()
would if working remove spaces, which would mess up the html itelf.
This is the result I get:
<style>
#element{
background: red;
}
</style>
<div id="element">
this is my element
</div>
This is the desired result:
<style>#element{background: red;}</style> <div id="element"> this is my element </div>
Thanks.
trim
only removes spaces from the beginning and end of a string. The usual solution is to serve html gzipped, which is much more effective and most servers support it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.