Forum Moderators: open

Message Too Old, No Replies

How to delete extra white spaces from HTML?

Any tool for it?

         

iThink

11:07 pm on Oct 4, 2003 (gmt 0)

10+ Year Member



I hope this is the right forum for this question.

I recently took a job of maintaining a website which has around 300 pages (all static HTML pages). All the pages are at least 55KB+ in size. This big page size is partly due to extra white/blank spaces incerted by a coder who was just too happy to use "enter" key or spacebar of his keyword. For example there are extra lines in javascript that is present in many pages and some 5-6 extra blank lines between </body> and </html> tags. Deleting these extra spaces will bring the page size down by around 12-15 KB.

Is there any shareware of freeware program available somewhere to get rid of all the extra white spaces and unnecessary lines in the HTML code of all the pages of a website in one go. I'll save a lot of time even if I can find something to do this job one page at a time.

amznVibe

12:05 am on Oct 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There are lots of tools to kill whitespace, for example one freeware tool that will leave it still readable but kill extra stuff is HTML Unoptimiser.

There are tools that will go even further but you might be best off leaving it readable for editing and install some html compression like mod_gzip )if you are fortunate enough to be on an apache server). Mod_gzip will give you a much more radical page size reduction to most visitors (at least 50% of the current page size, usually more).

iThink

1:09 am on Oct 5, 2003 (gmt 0)

10+ Year Member



Actually HTML Unoptimiser is doing exactly reverse of what I need to do. It is formatting the HTML code and adding a lot of white spaces to increase the size of page but I got the idea from your post to search for key phrase "HTML optimizer" and got shareware from there. Sometimes right keyword is all you need to search for the right stuff.

Thanks.

Hawkgirl

11:43 am on Oct 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's an online tool called "Doctor HTML v6" - it's free. It will analyze a single page for you (just type in the URL and hit "Go!"). It has an option that will return "squished" code to you - just make sure that the "Squish HTML" checkbox is checked before hitting "Go!"

A friendly word of warning: keep an old copy of your non-squished HTML on hand for when you need to make edits. That squished code will give you a serious headache and makes edits nearly impossible! :)

iThink

1:38 pm on Oct 5, 2003 (gmt 0)

10+ Year Member



Thanks for the suggestion. Doctor HTML is even better. It reduced the size of the index page from 55kb to 34kb, that is an almost 40% reduction in page size.

Hawkgirl

2:37 pm on Oct 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yep, I've used it frequently. Glad you found something that works for you.

sun818

3:43 pm on Oct 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



A free command line tool (Linux/Win32)I ran across a few days ago called Hzip will do what you want. It's smart enough to leave JavaScript alone. It reduced CNN's home page from 61k to 57k. I used to reduce white space manually, which was a chore. But now I just include this program as part of a batch file before I send my files to the web site.

g1smd

8:34 pm on Oct 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



A simple Find and Replace in a text editor can get rid of spaces (but not tabs or carriage returns). Find {space}{space} and Replace with {space} should do it.

If your site has a lot of pages, some other (more-automated) method is necessary.

However, there is a design methodology that you have to consider first. Are you going to reduce your pages and use them as your editing copy and your upload copy, or are you going to keep the formatted pages as your editing copy, compress those pages and upload the compressed version keeping the uncompressed versions for future editing?

sun818

8:56 pm on Oct 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have to take back my recommendation of Hzip. I tried it for a week but it's still buggy and does some weird stuff with makes spaces in your HTML display funny. I'm currently testing out ahc (absolute html compressor) which has command line options. I suggest you try turn all the "compression" options off and experiment with one at a time. Once you're comfortable with the results try the next option. I accidentally had it compress a folder last night and it took me several hours to reverse the effects.

ncw164x

9:02 pm on Oct 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have used HTMLshrinker for over 2 years and it's a very good program and so quick.
You can shrink 100's of pages in seconds with the option to save a back up of the original page