Syntax Highlighting vs Bandwidth

Recently there was a discussion on HTTP compression and how it should generally be enabled, to save bandwidth for the publisher and for the subscriber.  But the best way to save on bandwidth is not to require so much of it (ie, to have lighter pages).

Syntax highlighting is a perfect example.  It makes code a little easier to read, but the expense of using an automatic syntax highlighting generator is pretty high.  Lets say I wanted to give you a little example of an httpModules element in some XML.  Look at this example:

<httpModules>
  <add type="classname,assemblyname" name="modulename"/>
  <remove name="modulename"/>
  <clear/>
</httpModules>

What you're looking at is 129 characters.  By the time it got HTML encoded (so that the angle brackets wouldn't be interepreted as HTML markup) and I added the font and blockquote and elements to make it look like Courier, it was 298 bytes - 2.3 times as large.  That's not so bad, because these are things that are necessary to go from XML to HTML.

However, let's add some syntax highlighting:

<httpModules>
  <add type="classname,assemblyname" name="modulename"/>
  <remove name="modulename"/>
  <clear/>
</httpModules>

The HTML being generated is pretty ugly - do a View Source and have a look.

This is code pasted in from Visual Studio .NET - all I did is take the plain text XML, paste it into VS.NET, and then copy it and paste it into my weblog editor.  The HTML has now grown from 298 bytes to 1268 bytes - 4.2 times as large as the plain HTML alone.

This is the VS.NET editor - other editors do a worse job.  I saw this same block of text expanding from 298 bytes to nearly 3k in a different editor.  How much information does the syntax highlighting add?  Is it worth it? 

You might want to take a moment and do a View Source on your own pages to make sure your tools aren't doing things you don't expect.