Standards vs. Speed
A few months ago, I came across an article named “Web Developers: Speed up your pages!” Yes, it was written in November 2005, but that’s just like me - late to everything!
I read through the article thinking that it would contain valuable advice which I could use in order to speed up load time (which was a problem I had for quite a while before I finally found a way to fix it). However, as I went through it, I found that much of the advice seemed either to be flawed or contradictory to web standards (especially XHTML). Therefore, I’ve decided to look at each point in turn and discuss whether it’s really necessary and whether it’ll actually make that much of a difference.
Tip #1: Strip spaces, tabs, CR/LF from the HTML
I agree that removing some extra spaces and tabs can result in spectacular speed increases, but removing every single HTML comment and space will result in code that is virtually unreadable. Will any webmaster be willing to update that when it comes to a refresh? Also, not using quotes on attributes is a big no-no, especially when using XHTML. Just no.
Tip #2: Don’t use XHTML
Yes, it is very controversial. I happen to disagree completely with this point. Do you think that nice clean and lean XHTML will take longer to load than the convoluted tag-soup code that was all the rage in the 1990s? I don’t.
Tip #3: Keep Cookies Small
This point I happen to agree with. If you have lots of data to pass around, consider using sessions. All good web languages such as PHP support them natively.
Tip #4: Keep JavaScript Small
Again, just like tip #1, you might be able to strip some extra spaces and comments from your scripts, but don’t go over the top.
Tip #5: Use Public Caching
Yes, but services like Akamai cost many thousands of dollars, so this is something for the very large websites with equally large budgets. For everyone else, just stick to private caching.
Tip #6: Enable HTTP Compression
Good idea. Ask your web hosting provider if they support compression. If they do, then consider using it.
Tip #7: Keep all as much as possible in lower case
This will also help you write valid XHTML.
Tip #8: Avoid Tables
A good point, but not for the reasons outlined. Try to avoid tables as a principle of good design.
Tip #9: Set image size
A minor point. One rendering won’t cost much in terms of time, but consider this if you have a page with lots of images.
Tip #10: Compact your GIF/JPG
Even better, use PNGs with PNGCRUSH for the best results.
Tip #11: Reduce the number of external elements
Embedding scripts verbatim in every single page you serve is very wasteful. One more trip to get an included script file which will then be used from the cache next time will take much less time than getting the script fresh with every page.
Tip #12: Use a single DNS Lookup
“Creative domain names” (aka subdomains) are sometimes required because content is served from different servers, especially with images and multimedia content like videos. Lookups take a fraction of a second each, so what’s the problem?
Tip #13: Delay Script Starts
Firstly, for some scripts, you have to do this anyway because they rely on the whole page being loaded and rendered when they run. Secondly, it’s better to use unobtrusive JavaScript rather than inline onload attributes.
Tip #14: Watch for Memory Leak
If a browser has a problem with memory leaks, then won’t it be better to report that problem to the manufacturer?
A few good points but a disappointing article overall.