Web Marketing: How to Avoid Excess Web Page Code

As a web marketer, avoiding excess code works to your advantage. Search engines like to see a high ratio of content to code: as few lines of code as possible per line of content. You have a few simple ways to remove code bloat and maximize the ratio of code to content.

Code using standards

If you code using XHTML and CSS standards, you can automatically minimize code bloat. These standards keep the code that controls how things look in a single, separate CSS file, and put all the content in the XHTML page. This setup maximizes that ratio of content to code.

One critical benefit of coding with standards is that you can stop using HTML tables for layout purposes. Tables are meant to display data, not graphics.

If you want to become more familiar with XHTML, take a look at HTML, XHTML & CSS For Dummies, by Ed Tittel and Jeff Noble (published by John Wiley & Sons, Inc.).

Remove inline JavaScript and CSS

Another code-bloat culprit is JavaScript that’s inserted right into the page.

image0.jpg

That JavaScript code doesn’t have to be there. Instead, you can move it into a separate .js file and include it by using JavaScript, such as

<script language="javascript" type="text/javascript" src="thescript.js">

You just removed 20 lines of bloat from your page.

You can do the same thing with blocks of CSS information.

image1.jpg

Move that CSS code to a separate .css file by using this code:

<LINK REL="StyleSheet" HREF="style.css" TYPE="text/css">

Congratulations! You just removed another ten lines of code bloat.

When you put JavaScript and CSS information into separate files, visiting web browsers will cache the information on the users’ hard drives. They download the scripts and CSS once and then load it from their own hard drives from then on. That speeds site performance and means that you use less bandwidth. Also, by putting these files in one place, you can more easily make site-wide changes and additions.

blog comments powered by Disqus
Advertisement

Inside Dummies.com