Web Page Sizes
Back to the site optimization theme I've written about lately ....A lot of attention is paid to file size when working with web sites and web applications. Specifically, there is a lot of literature on compressing Javascript files (by the way, the best way is to use Rhino or the Dojo toolkit which has built an online tool, ShrinkSafe) and tweaking images and graphics for fast, faster, and fastest load times.
Sometimes web developers forget about optimizing the content!
On a recent web project, our team noticed that the pages were taking longer to load than necessary. I noticed my FasterFox timer had gone from a few seconds to over 15 seconds on some pages. We began digging into the first culprits (Javascript and graphics) and concluded that neither were the issue. Javascript was well compressed using a custom ant target (which uses ShrinkSafe to compress the javascript), and the images were at a reasonable size, well under 100K for the whole page.
I decided, somewhat haphazardly, to look at the source code on the page that was taking some time to load. I saved the HTML code as a new file, and checked the file size. At over 65,000 lines of code, the HTML file, alone, weighed in at over 3.3 MB. That is huge, considering that our average page size is between 12K and 45K. After doing some more digging, it appears that 86% of the 3.3MB file is white space ... specifically, spaces and newline characters.
The culprit? A developer, who was using spaces instead of tabs. A simple, and common, IDE setting was inflating a page from under 500K to over 3.3MB. Several JSP files, with loops in them, had hundreds of spaces that expanded in our application to thousands upon thousands of white spaces.
Lesson learned: Use tabs, not spaces, when programming or coding.
0 Comments:
Post a Comment
<< Home