Reputation: 409
To take away some page loading time, where can I find something to remove spaces between html tags? Without me having to go through each one and remove them myself
Like so:
<body>
<p>Lot's of space</p>
</body>
<body><p>No space</p></body>
I found this site. But it leaves one space between tags. But I don't want any.
Upvotes: 1
Views: 3619
Reputation: 1115
Be careful that you have some idea of what is happening or you will corrupt the integrity of your documents. A fully minified code sample removes all comments and all white space characters not necessary for syntactical purposes.
In other words this example of HTML:
<p>Some content
<strong>is strong</strong>
and
<em>emphasized</em>
in this paragraph.</p>
When fully minified becomes:
<p>Somecontent<strong>isstrong</strong>and<em>emphasized</em>inthisparagraph.</p>
In that case the corruption to the content is obvious as all the words are colliding into each other. What is not obvious is the space buffering content and tags and the spaces between tags not adjacent to other content. All white space characters outside of tags in a HTML document are text nodes in the DOM and removing DOM nodes without careful consideration is possibly harmful.
Furthermore, you also have to ensure that your HTML minifier is not corrupting any inline JavaScript or CSS code. Investigate these conditions carefully when looking at the different options available.
Here is one that I wrote which may be helpful to you as it minifies markup tags in a way that is fully recursive to a beautified state using an automated pretty-print application.
http://prettydiff.com/?m=minify&html
Upvotes: 7
Reputation: 1047
I'm developing web application with Smarty template engine. It has function {strip}, which replaces all new lines, tabs, spaces... in the template. So you can write your code with many new lines and spaces. But output will be in single line.
Upvotes: 0
Reputation: 3931
Any other HTML minifier without this rule will work.
Google listed me this one:
http://www.willpeavy.com/minifier/
Upvotes: 0