ASP 101 - Active Server Pages 101 - Web06
The Place ASP Developers Go!

Windows Technology Windows Technology
15 Seconds
ASP 101
ASP Wire
VB Forums
VB Wire
internet.commerce internet.commerce
Partners & Affiliates
ASP 101 is an site
ASP 101 is an site
Internet News
Small Business
Personal Technology

Corporate Info
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash

 Top ASP 101 Stories Top ASP 101 Stories
Connections, Commands, And Procedures
What is ASP?
VBScript Classes: Part 1 of N

Encapsulate business logic in components
Show All Tips >>
ASP 101 RSS Feed ASP 101 Updates

Quick Tips

Watch Your Whitespace

While this isn't technically an ASP tip, it's worth mentioning anyway. What's the difference between these two sets of HTML?

Set 1
        <title>Page Title</title>
        <p>This is some text</p>
Set 2
<html><head><title>Page Title</title></head><body><p>This is some text</p></body></html>

I know what you're thinking... "That's easy... the first one's readable!" and you're absolutely right, but readable by who? While I whole-heartedly support readable code, most HTML is meant to be read by browsers and not people. To a browser, the two sets of code above are identical except for the fact that the first one is over 50% larger (142 bytes vs. 90 bytes) and takes that much longer to download and display!

Don't get me wrong, I'm not saying you should take out all your spacing and carriage returns, but poorly written ASP can add a lot of extra whitespace to the resulting HTML. This whitespace not only slows everything down, it actually causes more work for your web server and uses more bandwidth. So take a look at your site's HTML every once and a while and make sure it's not getting out of hand.


Note: I realize a lot of you are rolling your eyes and shaking your head at this, but it really can make a difference. I was recently working with a community-based portal site who was having some performance problems. The HTML to their home page was just under 33k. I was amazed to find that without even breaking a sweat (and leaving almost all the formatting intact!), we were able to cut it down to 24k! Almost a third of the page was totally worthless spacing. They were reluctant to strip all whitespace, but I'm sure we could have gotten that page down to under 20k pretty easily without really changing anything!

And if that doesn't convince you, take a look at the source to Yahoo's homepage sometime. You'll find very few extraneous tabs, spaces, and carriage returns. The most popular site on the internet needs to do all they can to optimize and they certainly took this tip to heart!

Previous      Show All Tips      Next

If you have a tip you would like to submit, please send it to:

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback
The Network for Technology Professionals



Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers