Wednesday, March 28, 2007

Optimizing Web Pages

Something had been nagging me for quite some time. The home page of my website took way too much time to download. And I am talking of a 100 Mbps broadband connection. Now if this was my take on the page, then the ordinary users’ reaction, with a standard 33.6 Kbps Dial-Up was definitely not going to be encouraging. So as soon as I got some time away from the client’s never ending modification requests ;). So I decided to get to the bottom of this and see if I was not being just paranoid. Here are some of the findings, (for obvious reasons I have removed the actual URLs in question)

test URL1

Download Times*
Connection Rate Download Time
14.4K 200.10 seconds
28.8K 105.35 seconds
33.6K 91.81 seconds
56K 59.33 seconds
ISDN 128K 25.52 seconds
T1 1.44Mbps 11.90 seconds
Comparing with some of our other websites,
test URL2

Download Times*
Connection Rate Download Time
14.4K 91.80 seconds
28.8K 50.80 seconds
33.6K 44.94 seconds
56K 30.89 seconds
ISDN 128K 16.26 seconds
T1 1.44Mbps 10.36 seconds

test URL3

Download Times*
Connection Rate Download Time
14.4K 137.93 seconds
28.8K 70.76 seconds
33.6K 61.17 seconds
56K 38.14 seconds
ISDN 128K 14.18 seconds
T1 1.44Mbps 4.52 seconds

It was time to get things in action. I dug up some material on the net. Most of the things I found were not news to me, and the rest seemed like plain common sense. And yet it was surprising how trying to meet impossible deadlines and keeping the clients happy, they had been conveniently forgotten, by me of course: P, during the development phase.

Well below is a small summary of the tips I found useful, followed by the respective links.

The basic idea is to
1) Reduce the number of bytes being transferred over the net
2) Reduce the number of individual HTTP requests per page load and
3) Increase the number of concurrent HTTP requests by spreading out content on multiple servers

Page Layout and Size
o 30K – the ideal maximum size for your Web page,
o 12K the ideal maximum size for each image, sound file, or applet This includes animated images and anything downloaded with the page
o Use multiple pages Instead of one long page
o Use special effects sparingly Make sure that the site needs the effect you want. Whenever you add Java or JavaScript or other effects, it impacts the download time of your site.
o Use CSS for layouts instead of Nested tables - Normally, when a page loads the browser starts at the top of the HTML and loads it sequentially down the page. However, with nested tables, it has to find the end of the table before it can display the entire thing. Also, if you're trying to write valid XHTML, tables should not be used for layout at all. Tables are for tabular data (such as spreadsheets) not for layout. Instead you should use CSS for layout - this renders more quickly and creates valid XHTML.
o A table will load more quickly if each row is a separate table, because the browser would render the first table and then render the second.
External Objects
o Use external stylesheets and Javascript files wherever possible. Since once they are downloaded, they will be cached by the browser, and the subsequent downloads will be much faster. For this, however, you must include the stylesheets and javascript files in the head part of the HTML page, instead of the body. Also, allow static images, stylesheets, and javascript to be unconditionally cached by the browser.
o Consider evenly spreading uncache-able objects over multiple hostnames, thereby allowing for more concurrent HTTP connections.
o Load fewer external objects. Due to request overhead, one bigger file just loads faster than two smaller ones half its size.
o Turn on HTTP keepalives for external objects
o Set an Expires header on everything you can, with a date days or even months into the future thereby reducing unnecessary HTTP requests for validating the cached content
• Using CSS effectively
o Use contextual selectors
Instead of assigning a value to each individual paragraph, we can nest them within a <div> tag and assign a value to this tag:
o Use shorthand CSS properties
You can use the following shorthand properties for the margin CSS command.
Use:
margin: 2px 1px 3px 4px (top, right, bottom, left)
...instead of
margin-top: 2px;
margin-right: 1px;
margin-bottom: 3px;
margin-left: 4px
o Use relative call-ups
Try to avoid absolute call ups as they take up more space. An example of an absolute call up is: <a href="http://www.URL.com/filename.htm">. Much better would be code><a href="filename.htm">. But what if some files are in different folders to other ones? Use these shorthand properties:

  • <a href="/"> - Calls up http://www.URL.com

  • <a href="/filename.html"> - Calls up http://www.URL.com/filename.html


  • <a href="/directory/filename.html"> - Calls up http://www.URL.com/directory/filename.html

  • <a href="./"> - Calls up index.html within that directory

  • <a href="../"> - Calls up index.html one directory above


  • <a href="../filename.html"> - Calls up filename.html one directory above

  • <a href="../../"> - Calls up index.html two directories above



o Remove unnecessary META tags and META content
Most META tags are pretty much unnecessary and don't achieve very much.
o Use / at the end of directory links
Don't do this: <a href="http://www.URL.com/directoryname">
Do this instead: <a href="http://www.URL.com/directoryname/">
The presence of the slash "\" at the end woluld tell the browser that the destination is a directory which, the browser would otherwise have to find out for itself.
Optimize GIFs
o Make sure that only the relevant parts are in the image. Cropping can make your Web image smaller both in dimensions and download size.
o Saving a three color file as a 256-color indexed GIF will increase the size. When saving as a GIF, it's a good idea to convert the image first to Web colors (if you're using Photoshop, choose the image mode, indexed, and then choose Web colors). This will make sure that the colors won't dither on the Web. Then convert the image to the least number of colors it can use and still look correct.
o GIF images use an index of colors for the image, colors that are not used in the image, don't need to be included in the index.
Remove Extra whitespaces
o Remove multiple carriage returns
o Close tags on the same line you open them on
o Keep related block items on the same line For example, paragraph tags or table cell tags should be on the same line as their contents,
o Indent using spaces And only use one space for each indent. You get the same effect, and use less whitespace.
• Use Google's Load Time Analyzer extension for Firefox from a realistic net connection to see a graphical timeline of what it is doing during a page load.

(..Excerpts from)

Webdesign/Speed
Webdesign/Optimizing Images
Musings
Webdesign/Tips

Saturday, March 10, 2007

WHAM!! WHAM!! THUD!! THUD!! Dear God!! My head hurt so much it was almost as if the
splitting sounds were coming from the outside. And they kept coming closer. Oh NO! Wait! They WERE coming from the outside. I looked up to realise there was cabling
work going on right at my desk. "Madam, can you please move outside, we need to move
your table and finish the cabling" .... I reluctantly got up from my seat where I
had put my head-down on my arms and closed my eyes, trying to shut out the noise. I
left to see if the coffee machine had been set up. I badly needed a cup. We had just
moved into our new office and it was the first day. The move was from a semi-
deconstructed to a semi-constructed office and life , as can be expected, was
chaotic, and I am not talking about just work. Scattered furniture, half-laid
cables, and non-stop hammering & drilling everywhere. I hadn't had a coffee since I
arrived 4 hours ago, and the drill machines had given me a splitting headache.It was
a nightmare. At last I found the coffee machine, and realised once again, how
heavenly a cup of coffee could be. :) Refreshed after that short break, I finally
forced myself to look around the place. And realised that it was not only bigger but
also much much nicer. Loads of windows everywhere, and a lot of moving space. The
view outside the windows was nothing spectacular, but I could see till far-off,
trees, mingled with single storey buildings, the perfect blue skies and the cool
wind on the perfect March afternoon. It was actually a nice place. The next day was etter, we even had a small ganpati-pooja, completely in-house ofcourse ;) and after we had finally managed to drag our CEO out of his non-stop meetings and embarrassed him visibly ;). This followed a samosa-party , well no celebration is ever complete without a samosa-jalebi party rt!! ;)
Its been a week. The drill machines are still on. But the cabling around my desk is done atleast ;) And, things are settling down.
Infosys founder said in a mecture, "Love your job, not your company" , I dont think thats possible. I dont think you can enjoy your work, unless you like the sorroundings, the ergonomics and the people you work with. Its the whole picture that can be viewed and taken in totality. Maybe that, or maybe I am too retarded to understand that :P
Well, its a saturday afternoon, and part-of-why I am still sitting in my office is because slowly, but surely, I am falling in love with it, all of it :)

Wednesday, February 28, 2007

shit! no1 agrees i shud be in s/w

not even my own intelligence ... :P

Your Dominant Intelligence is Interpersonal Intelligence

You shine in your ability to realate to and understand others.
Good at seeing others' points of view, you get how people think and feel.
You have an uncanny ability to sense true feelings, intentions, and motivations.
A natural born leader, you are great at teaching and mediating conflict.

You would make a good counselor, salesperson, politician, or business person.


hmm....maybe i should finally talk to my parents.... ;)

Thursday, February 22, 2007

i am thai...

.... food i.e. atleast thts wat the results say :P

You Are Thai Food

Trendy yet complex.
People seek you out - though they're not sure why.


and come to think of it, i dont even like thai food ;-??

Sunday, February 11, 2007

happy valentine's day ;)

last night, while i was waiting for some droll work realted files to download and generally hating my life, i started browsing through the net, something, the net content made me realise, i havent done in a realllllly long time. neways, owing probably to the valentine's day fever, i kept running into v-day ads and banners of gift vouchers, and cards and ballons and oh-so-many-red roses, so just out of my insatiable curiosity, i clicked on one of the ads,

"This v-day ! Love, be-loved and appreciated....."

and the homepage completed the sentence

".....tips to kiss, love..." and many more such how-tos. now i am not against romance, but somethings are too amusing to be anything else actually ;) in search of such similar amusement, i read on...

so, the first page i landed on had the following content,
(its hilarious and i really cant stop laughing, )

Get your partner to the sea shore at sunset. Give her smile. Buzz a latest romantic song. Hold her tight and give a moist kiss.
==> dont forget to carry a good stereo system, her favorite song cd , a lip gel, reach half hour before sunset, prepare the ground, and by the time you are done, ofcourse you do realise you could've just stayed at her place, the sun does set around her roof as well

You are with your girl friend moving in the car. Stopped at a traffic light. Hold her hand and give a soft kiss.
==> and in case the signal suddenly turns green, im sure she'll not mind getting her hand crushed while you shift gears

Take a stop watch. Ask the girl to help you maintain a long kiss, longer than a minute and so on.
==> statuatory warning : lack of breath or sudden stopwatch alarms going off can cause injury so keep your mediclaim ready before doing this one & do this near a hospital :P

Make a sign of first letter of your partner’s name with your lips and slowly gently fix a kiss on her cheek.
==> hmm. now I know why Xena must have never gotten kissed

Order a pizza. With the help of tomatto ketchup make a sign of kiss on pizza. Ask her to make same sign with her lips at your cheek.
==> come again??

When you are travelling with her in a car. Tell her whenever we see a dog or any other specific animal, on road side, we will kiss each other. A good excuse.
==> so no one actually looks at the traffic while driving? and i think i cant drive!

Tell your love that something is there below her eyes. Ask her to close the eyes. Use the opportunity and give her a kiss.
==> ofcourse if during this time whatever is there actually bites her below the eye, then you could end up with a blue eye

Move in the rain without umbrella. Grab rain drops on your lips and then slowly place them on lips of your love.
==> i cant stop imagining a guy standing in the rain, cold and wet, trying to figure out why did the girl leave him, after all he was only grabbing his own lips repeatedly, trying to catch hold of a rain drop!!

when i stop laughing at imagining these mental images, i'll read on... maybe find-your-true-love-tips next time ;)

till then have a nice v-day. and avoid all kissing disasters if you can ;)