Are you using tabs or spaces to indent your markup? Does it matter for performance which one you chose? Let’s run an experiment.

Consider a page that generates a list of 50 items:

<ul>
    @for (int i = 0; i < 50; i++)
    {
        <li>The count is @i</li>
    }
</ul>

The code generates a long list of <li> elements and keep their indentation using the editor’s settings for tabs, spaces and tab size. Default in many editors is spaces and a tab size of 4.

With spaces it looks like this:

image

and with tabs it looks like this:

image

It’s clear to see that the indentation takes up 4 characters when spaces are used and only a single character when using tabs. If we then compare the total file size of the two variations, here’s what we get:

TabsSpacesSaving
Raw file size1403 bytes1703 bytes300 bytes/18%

Using tabs saves close to 18% of the file size over spaces.

This is, however, not a true picture of a web page. All modern web servers use compression in form of GZip or Deflate before serving HTML to the browser. So let’s look at the numbers after GZip:

TabsSpacesSaving
Raw file size1403 bytes1703 bytes300 bytes/18%
Raw file GZipped   327 bytes   332 bytes     5 bytes/1.5%

When using GZipping, the saving from using tabs over spaces is just 1.5%. It’s still a saving and it counts.

Yet again, this is not the complete story because some web developers make sure to minify the HTML by removing redundant whitespace, unneeded quotation marks etc. Normally this is done as a build step or at runtime.

So let’s minify the HTML and see what results it produces:

TabsSpacesSaving
Raw file size1403 bytes1703 bytes300 bytes/18%
Raw file GZipped  327 bytes  332 bytes     5 bytes/1.5%
Raw file minified 1199 bytes1199 bytes     0 bytes/0%
Minified & GZipped  312 bytes  312 bytes     0 bytes/0%

When minified, it doesn’t matter if tabs or spaces are used, since they are all stripped away.

Conclusion

Depending on the capabilities of your server, build setup, runtime etc., here’s a little chart of what to do based on the above findings:

Use tabs or spaces
I can minifyDoesn't matter at all
I can GZip but not minifyDoesn’t matter much (tabs gives small benefit)
I can neither GZip nor minifyTabs

Keep in mind that this is a controlled experiment, so your mileage will vary.

If you want to enforce your entire team to use either tabs or spaces, then take a look at .editorconfig. There’s a plugin available for practically all editors.

In the next segment, we look at the effects of GZipping vs. minifying HTML files.

tl;dr

You need to update Web Essentials 2013 to version 2.2. If not, Visual Studio will crash. Download now.

Before Visual Studio 2013 Update 3

The upcoming release of Visual Studio Update 3 has API changes in some of the components that Web Essentials is extending. Those changes are not compatible with the current version of Web Essentials and will cause VS to crash after upgrading to Update 3. To be fair, those APIs were never public to begin with, so I was taking a chance when I was using them in Web Essentials.

If you are currently using Web Essentials 2.1 for Visual Studio Update 2, you should see this dialog show up the next time you open Visual Studio.

Web Essentials update notification

This is the first time this notification feature has been used after introducing it in Web Essentials 2.1. Good thing we did.

It’s important that you install this update immediately. You don’t have to restart Visual Studio – it’s enough that you just install the update. If not, you might forget to do it before you install Visual Studio Update 3. So go do it now.

It turns out to be good timing, since we have added some cool new features in version 2.2. Here’s a list of a few of them:

This is unfortunately the price we have to pay to be on the cutting edge. Lesson learned and we’ll do our best to make sure this doesn’t happen again. It’s not a guarantee since Web Essentials will continue to use APIs that are unsupported by Microsoft. That’s the only way we can add all those cutting edge features.

Download Web Essentials 2.2