views:

1526

answers:

6

Does anyone know a good tool that can be run on a page (for asp.net, for example) to help to minimize the footprint size of the page?

The page will have typical items: HTML, Javascript, etc.

I've heard of Javascript crunchers in the past, that will make the size of the code as compact as possible (and obfuscate it, I suppose).

The goal is to help optimize the page size (make it as small as possible for speed, without changing anything).

Is this possible?

+3  A: 

Well, its not a automatic cleaner-upper, but I like YSlow for optimizing pages. And the YUI Compressor can minify your javascript.

If you're really interested in javascript, the keyword is "minify".

Also, look at this question just posted: HTML and stuff

Hope that helps!

Zachary Yates
+4  A: 

You could configure your web server to compress the page on the fly (and possibly cache the compressed version) for any client that indicates it can take a gzip or zip (or other) encoding, which is pretty much all of them.

Software Monkey
That is an excellent suggestion. You should still try to avoid errant HTML code, especially on higher traffic sites, right?
pearcewg
@pearcewg: How/why would you have errant HTML (which is not code btw, it's markup)? You either write what you intend to show or you don't. I definitely wouldn't have tons of comments, if that's what you mean.
Esteban Araya
+2  A: 

Yep, definitely. I am not an asp.net guy, but things you could look for (as others have said):

  • gzip compression for the page - a server option
  • js: like you said, there are minifying options for javascript, which in turn can be gzipped as well.
  • css: there are minifying options just like javascript, and can also be gzipped.

Our java apps use pack:tag. Maybe you could find a similar .net replacement.

Yslow, already mentioned, can show what improvements you can make.

lucas
+2  A: 

Search for some ASP .NET Compression techniques, if you're on IIS6 I recommend you MbCompression, however if you're running IIS 7 it has great built-in HTTP compression support, you can define which files get compressed based on their MIME type in your configuration files.

CMS
+1  A: 

A bit of fundamentals: IIS saves compressed response of JS/CSS/Html files on disk so, subsequent requests for JS/CSS is served from Disk(bypassing step of compression). While compressed response for ASPX/ASCX are not cached on disk, since response varies from request to request.

Therefore, Best practise is to keep Javascript/CSS in their own files and avoid putting inline CSS/Script in aspx/ascx.

Broadly there are two ways to reduce Page-Size/HTML 1) Compression by webserver/HTTPModule [Enable IIS 6 HTTP Compression][1]

2) Obfuscation/compression by third party tool - JASOB is my favourite one.

It can also compress/obfuscate javascript/css code from your php/asp.net/perl/jsp/XSLT file. And If like vanila DOS then there's command line interface too.

I have used it in several ASP.NET projects, I just select my webproject directory and JASOB provides nice option to publish obfuscated version of webproject directory. This means it obfuscates javascript/css from all files lying under your webproject directory and yeah it traverses sub directories too. And All of this in one click.

Hope it helps, Maulik Modi http://www.jasob.com/Features.html

[1]: - http://msmvps.com/blogs/omar/archive/2006/08/10/iis-6-compression-quickest-and-effective-way-to-do-it-for-asp-net-compression.aspx

msqr
+1  A: 

I personally would not sacrifice readability and maintainability for size.

Dynamic web server compression saved me a TON (given text compresses so well), and further optimization would have gained me very little.

dicroce