If the web was smaller
I’ve just had this crazy idea, what would happen if all the <div> tags in the world were converted into <d> tags. Image how much space it would save, well you don’t need to imagine I have broken out my calculator and worked it all out.
Taking the top 5 website’s from Alexa:
| Website | Number of <div> Elements | Size | Size when <div> = <d> |
| Yahoo.com | 85 | 153Kb | 152Kb |
| Google.com | 6 | 7.5Kb | 7.5Kb |
| Youtube.com | 377 | 76.8Kb | 75.3Kb |
| Live.com | 27 | 18.6Kb | 18.5Kb |
| MSN.com | 140 | 48.9Kb | 48.3Kb |
Approximate byte size per 2 characters.
For every element that would be converted to a <d>, on average 5.93 bytes are saved. Considering that a typically website has 127 <div> elements, taking from the average of the top 5 website’s, this will create a saving of 0.753Kb per web page. That might not seem like a lot but added together across all the website’s imagine how much time it would save.
Of course this is just pie in the sky, but if the W3C thought of shrinking the HTML tags we use, website’s would load faster, and every millisecond counts. Hopefully this will cause some debate on why HTML elements are longer than they need to be.
I am only suggesting the HTML tags div and span since they convey no semantical meaning, unlike elements like p.




Have you considered gzipping the results and seeing if it’s really worth it?
True, gzipping is a much better way of shrinking the HTML code. However it is not fully supported on all browsers, and some people are just lazy and don’t implement gzipping.
Done a bit of the old practical testing …
jearle@sausages$ curl -s http://www.youtube.com/ | wc -c
71339
jearle@sausages$ curl -s http://www.youtube.com/ | sed -e ’s/div>/d>/g’ -e ’s/<div//d>/g’ -e ’s/<div/<d/g’ | gzip | wc -c
12899
So, while it sounds like a good idea, gzipping reduces the advantage considerably. Why not just insist everyone gzips everything?
Yeah, gzipping should be enforced. It would be a lot better and more efficient.
not convinced those savings are remotely worth it to be honest……
I cant agree on the “gziping should be enforced” part. First, you’ve said yourself that not every brwoser supports it. True. And remember that not only browsers are used to browse the Net, but sometimes you’ve got to fetch XML, pocke a hole in some sockets etc. Then both you and the server has to spend time (read: CPU cycles) gziping/ungziping the data and I can bet the time spent on that is far greater than sending another 1k bytes.
And the “127 div’s for page” is absurd. 127 divs is a sign of :
a) something way to big – like yahoo – how many sites like yahoo have YOU written? :>
b) someone who dosn’t have any idea what he’s doing – I usually get sites done in ~20 div’s, rest goes in and the other bunch. Can’t shorten
Oh, and as for Jared’s example, gziping things that are still :
[root@~] curl -s http://www.youtube.com/ | gzip | wc -c
13022
So thats 123 bytes saved .. not that much really …
@BTM I wouldn’t agree that using 127 divs is a sign that you don’t know what you are doing many sites have a lot of content, or even a lot of round corners.
The fact is image how much space you would save in the entire Internet if all the div’s were converted into d’s.
The vast majority of requests are from browsers that support gzipping. The great thing about the HTTP protocol is that the browser specifies whether it can accept gzipping when it makes the request, so unsupporting browsers can continue as normal.
Grabbing XML is no different, just use a client library that supports gzip. Sometimes its nice to be able to talk standard text for simple apps, but relatively thats a tiny amount of traffic.
As for CPU usage, in most cases the the benefits of bandwidth savings outweigh the problems of using extra cycles.
I’m not saying gzipping should be mandatory, but more widespread web server support would save a fair amount of bandwidth.
Easy to do (though the real benefit is up for debate).
Send your pages as XML, use XSLT to transform the d’s to div’s on the client. If you’re doing that, you might as well shortcut all of your tags at the same time….
hello can someone pleas explain this:
“For every element that would be converted to a , on average 5.93 bytes are saved.”
div – d = 2
\div – d = 2
= 4 bytes
So when i replace i only get 4 bytes, not 5.93, what am i doing wrong?
@micho, you are completely right for every 2 characters there should be 4 bytes. However I worked that out on an average of the top 5 websites. My calculations may not be that accurate.
Think how much better many sites could be at describing the structure and hierarchy of their contents to user agents, if only they used more appropriate markup, instead of relying on so many generic div’s for everything…