Archive

Archive for August, 2010

Minify HTML with .NET MVC ActionFilter

August 10, 2010 9 comments

To make our site a tight as possible, I thought we’d explore the idea of removing the white space in our generated HTML.

I’ve had this idea for a long time, but after reading @hugoware post about removing white space, I decided to implement it in my own projects. As with any good code, let’s stand on the shoulder of giants and make it fit our needs.

Normally, if we did a “View Source” on our web page we would see something like this:

MVC Vanilla app, view source.

Now a lot of good HTML developers like to leave closing html comments and notes in their code. This helps them track end elements in nested code.  For example:

<div id="wrap">
    <div id="content">
     content goes here, with more elements of <>
    </div> <!--end content-->
</div> <!--end wrap -->

The issue we may face on larger pages is there can be a lot of notes and end line comments which can add to the overall size of your page, which the user doesn’t care about but the developer needs for easy editing later. Read more…

Categories: Code Examples Tags: , , ,

Cache for speed with .Net

August 5, 2010 1 comment

The better you can make your users experience the more they will like to use your site. One aspect is of this experience is speed.

Following on from my previous post, we will look at adding simple caching to our project for another quick win, this is just one method of many. Caching really depends on the size and type of your application and hosting environment. Read more…

Categories: Code Examples Tags: , , ,
Follow

Get every new post delivered to your Inbox.

Join 324 other followers