Clean Up That Code!



Get Web Design Tips and Tricks on mps-web-design.com. Clean Up That Code! topic will increase your understanding on Web Design Tips and Tricks. We at mps-web-design.com only provide news, articles, information in Web Design Tips and Tricks. Web Design Tips and Tricks at mps-web-design.com provides the most up to date news and articles. If you have questions please do not hesitate to contact us.

CLEAN UP THAT CODE!
by: windsong

How do you write your code so that it shows up on all or
most browsers the way you want it to look? By understanding
which browsers support which tags, and using a validation
service to check your code.

There are different tags that sometimes do the same thing.
The problem here, is that some browers read some tags and
not others. If the browser can't read your tags, it will
cause your page to appear in some way other than what you
intended. The trick is to write your code in such a way
that all, or at least most browsers can read and display
it the way it is supposed to be.

You will find an HTML Tag List at:
http://www.ncdesign.org/html/list.htm You can use this
as you are writing your code and avoid some pitfalls. It
only covers Netscape and Internet Explorer. These are the
most used browsers, and probably includes about 80 percent
or more of the online crowd.

You can check your html code by going to a validation
service like Net Mechanic. You will find a link to this
and other validation services at:
http://marketing-resources.com/utilities.html This can
be a humbling experience. It checks your code and gives
you all the errors and warnings.

Do your corrections, and check it again. You may have to
do this a couple of times to end up with no errors.

There is no reason not to have perfectly clean HTML code.
Learn the tags and which browers support them, and you
are almost home. Then just run it through a validator.
Now the world sees your page the way it really is.

Copyright © 2001, windsong

--------------------------------------------

Subscribe to windsong's free e-zine:
All About Web Design!(tm) Send a blank email to:
mailto:AllAboutWebDesign-subscribe@yahoogroups.com

Download a free ebook, 'Web Design Course' here:
http://marketing-resources.com/design.exe



DesktopMaster 2.0. - Enjoy the newest desktop themes And keep your computer clean! DesktopMaster is the #1 Software for your desktop themes!
Registry Cleaner-Registry Fix Mantra. - Maximum Conversion Rate - Award Winning Registry Cleaner & Registry Optimizer, Earn $30 per sale.

This post was originally published on May 13th, 2004. As others are writing about the topic, I thought bringing it out of the archives would be worthwhile.

A little recap

The idea of placing multiple states of buttons and other elements that are used in background images took its roots, I believe, from Pixy's Fast Rollovers. The CSS Zen Master extended this to another purpose in CSS Sprites: Image Slicing’s Kiss of Death. Didier Hilhorst came up with a nice application of this method, and I worked it backwards in Responsible CSS - Recycle your background images.

The idea behind the 'sprites' method can obviously be extended to any html element, and there are tangible benefits for doing this, just as long as the designer does his or her usual homework.

Benfits of using the 'sprites' method

What are the possible the benefits of using this method? Essentially it lies in faster download times for your web content.

Readers of Andy Kings book, Speed Up Your Site: Web Site Optimization will notice that this method reduces http requests and makes more efficient use of the data packets used to transfer files to the users computer, and that that is a good thing.

Packet size and http requests

From Web Page Design and Download Time, by Jing Zhi of Keynote Systems (seen here - pdf), cited in Andy's book:

The basic performance principle is therefore to make fewer requests and transmit fewer packets. From this principle, we can derive two basic design rules for wellperforming Web pages. First, reduce the overall size of the page, thereby reducing the number of bytes (and packets) to be transferred over the Internet. Second, limit the number of embedded objects on the page, such as images, each of which must be requested and transferred separately from server to browser.

They also found that it was the number of packets and not necessarily the overall size of the page that was important. If a packet could hold 1460 bytes (the figure given in the article) and your object was 1600 bytes, it would require two packets. They found that this object would transfer at the same speed as another object that was greater in size but still fit in two packets.

Potential payoff

The potential payoff for using this method versus individual images, then, is a faster download time due to reduced number of packets and fewer http requests.

Reducing http requests is easy. One file instead of two or three etc. is simple. But packet requests? That depends...

An example

The number of packets sent will depend on the size of the file and the users internet connection.

As an example, lets look at the fiftyfoureleven.com logo at the top of the page. When this design was first being coded, that link consisted of two 3.34kb images, one for the link state and one for the hover state. Now, by using one image that contains both states and simply bumping it back and forth depending on the hover state, that has been reduced to one 5.35 kb image. Right there is a savings of 1.33 kb. Good news.

Now, for arguments sake lets say that a packet can hold 1460 bytes (packet size for connections greater than 128kb/s = 1500 bytes -40bytes for tcp/ip headers). The two image method used 6 packets, 3 for each image (3.34/1.46, rounded up). The single image method uses 4 packets (5.34/1.46, rounded up).

Things are looking good.

How to optimize

In his alistapart article, Dave refers to the image that holds all of the sprites as his 'master image'. The key to benefitting from this method is to ensure that the file size of your master image isn't a bloated equivalent versus the sum of its pieces.

Conclusion

Great benefits can be realized when combining a master image from slices that fall well below the size of one packet, as that unused packet space goes wasted.

After doing a little more research, it seems that packet size can vary depending on the connection rate. That being said, it may be rather difficult to come up with a firm rule here. To play it smart and safe, try and:

  • build master images that are smaller then the sum of their collective slices (by combining images of similar colors, for example) or
  • rather than use a different distinct image for a certain element, reuse one that you already plan on using elsewhere.

This isn't exactly groundbreaking advice, however having seen the results acheived with the logo on this page, it can be seen that using the sprite method versus individual images at minimum does reduce http requests and even further it can reduce file size which in turn can reduce the number of packets sent.



Article Index: | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79


More Articles:


1. Seven Ways to Put Your Business Online And The One Guaranteed Way to Do It at No Cost
Ever since businesses realized that the Internet the ultimate resource to reach more people in less time for less than most other marketing mediums, business owners have been asking how can I get my business online and thus in the global marketplace. This question was answered with many solutions to include “my son took a web class in school, he can do it”. Well let’s look at the seven different ways to put your business online and the pros and cons of each. Do It YourselfThe first way would be …

2. Intelligent Design - Basic Design Guidelines
When talking about intelligent design, we are not talking about the creation of man. Nope, this is more important! The creation of your media and site products. There are some very basic things about design that one can learn that can vastly improve one's ability to make appealing and intelligent creations. Some of those things are: 1. Lining Things Up 2. Using Variation 3. Giving Breathing Room 4. Using the Grid 5. The Golden Section 6. Lining Things Up Things that line up look nice. Thin…

3. First Impressions
First impressions are extremely important if you hope to dobusiness on the Web. After you refine your ads, and if you makeyour pitch to a targeted group, you will start to get visitors toyour web site. Here is where many would be entrepreneurs dropthe ball.Putting up a web site is not a difficult task, but designing agood one is, and if you don't pay attention, it might be workingagainst you. Think about it, the web site is not only the firstimpression of you and your business, it is crucial to …

4. How to Use Scripts
Scripts are small pieces of code you install on your websiteto do very specific tasks, following a visitor's actions.The most common scripts for Webmasters are Javascriptsand CGI scripts. Though they can perform many other usefulfunctions, they are used best to gather information aboutthe customer's shopping habits.For example, you can have a script that will pop open whenvisitors first arrive at your site inviting them to joinyour newsletter and receive a fr'ee course on a relatedsubject.You c…