spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / authoring / languages / html / optimize 123456789

Extreme HTML Optimization

Developer News
SaaS Tool Offers Custom Database Development
Microsoft’s Automated Agent: Can We Talk?
Borland Finally Sells CodeGear

URL Abbreviation

One of the most effective techniques you can use to shrink your page is URL abbreviation using Apache's mod_rewrite module. First seen on Yahoo, the busiest page on the Web, URL abbreviation substitutes a short redirect URL (like "r/pg") for a longer one (like "programming/") using the mod_rewrite feature of Apache. This technique is especially effective for front pages which typically have a lot of links. We saved 5-6 K on our front page using abbreviated URLs.

To set up redirects first have your IT department install mod_rewrite on your Apache server. They'll need to edit one of your server config files. The following srm.conf commands show where to look for your rewritemap, and what the rewrite rule is:

RewriteMap      abbr            dbm:/apache/abbr_webref
RewriteRule     ^/r/([^/]*)/?(.*)   ${abbr:$1}$2    
[redirect=permanent,last]

Next enter the abbreviations you want separated by tabs in the above-referenced rewritemap file ("/apache/abbr_webref.txt" in our case). The following is a sample from our current redirects:

b	dlab/
d	dhtml/
g	graphics/
h	html/
p	perl/
x	xml/

3c	3d/lesson
dd	dhtml/dynomat/
ddh	dhtml/dynomat/hiermenus3/
dc	dhtml/column
gc	graphics/column
...

i2	index2.html
au	authoring/
in	internet/
iv	interviews/
mm	multimedia/
pg	programming/
pr	promotion/

th	tools/html/
tj	tools/javascript/
tl	tools/
tb	tools/browser/
tbj	tools/browser/javascript.html

hl	headlines/
hn	headlines/nh/

s	services/
sd	services/dns/
sf	http://forums.webdeveloper.com/
ss	scripts/
sg	services/graphics/
sr	services/reference/
...

ab	about.html
ns	new/submit.html
nc	new/contest.html

i	http://www.internet.com/
ic	http://www.internet.com/corporate/
...

is	http://www.internet.com/sections
isa	http://www.internet.com/sections/asp.html
isc	http://www.internet.com/sections/careers.html
isw	http://www.internet.com/sections/webdev.html
isd	http://www.internet.com/sections/downloads.html
isi	http://www.internet.com/sections/international.html
isx	http://www.internet.com/sections/linux.html
...
iswn	http://www.internet.com/sections/win.html
iswl	http://www.internet.com/sections/wireless.html

en	http://e-newsletters.internet.com
enm	http://e-newsletters.internet.com/mailinglists.html

icl	http://www.internet.com/corporate/legal.html
icp	http://www.internet.com/corporate/privacy/privacypolicy.html
ert	http://www.earthweb.com/
fkt	http://www.flashkit.com/
...

So to link to our privacy policy all I have to do is now type <A HREF="/icp">Privacy Policy</A> saving beaucoup bytes. Notice that I use shorter abbreviations/redirects for the more frequently used URLs, like our experts ("r/d" = "/dhtml/"). I save even more space with the tutorial abbrevs that automatically append the column number after the fragment URL thus ("r/dc/48" = "/dhtml/column48/"). Major directories are two characters, and start with the same letter when possible ("s" for services, "h" for headlines etc.). Internet.com links start with an "i" and other sites all have three-letter abbreviations for consistency.

To add more abbrevs you just edit the rewritemap file, and run something like:

"create_dbm abbr_webref abbr_webref.txt"

in the "/www/misc/redir/" directory. Remember to use TABS to separate the two fields, and test before deploying. Yahoo uses redirects like this on their home page to great effect (load time is nearly instantaneous). This technique alone saves us 5-6 bytes off the 24K hand-optimized home page.

Quotes

Some quoted attributes are optional in HTML 4.01, and can be safely ommitted from your HTML. Note that XHTML requires all attributes be quoted, and complete (checked="checked" etc.). Attributes must be quoted if they contain any character other than letters (A-Za-z), digits, hyphens, and periods. So you can do this:

<IMG SRC="t.gif" WIDTH=1 HEIGHT=1>

but not this:

<TABLE WIDTH=100%>

While not technically valid HTML, quotes can be ommitted from A HREFs like this:

<a href=r/pg></a>

The links still work on every browser we tried, and we actually got the front page down to the 13K range using this technique. Here's an example. However, for XHTML all attributes and URLs must be quoted, so we recently switched to quoting URLs to have a valid page (sans the ad code's ampersands).

home / authoring / languages / html / optimize 123456789

http://www.internet.com
Comments are welcome


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Microsoft Article: 7.0, Microsoft's Lucky Version?
Microsoft Article: Hyper-V--The Killer Feature in Windows Server 2008
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Windows Server 2008
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES
webref The latest from WebReference.com Browse >
How to Create an Ajax Autocomplete Text Field: Part 6 · Software Engineering for Ajax · Perl Pragma Primer
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Using File Virtualization for Disaster Recovery · VoIP Security: SIP—Versatile but Vulnerable · Around the World in 80 Nodes

Created: Jan. 10, 2000
Revised: Mar. 19, 2001
URL: http://webreference.com/authoring/languages/html/optimize/part2.html