• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
  • Tim Holloway
  • Carey Brown
  • salvin francis

Insertion of css, Java Script and Images

Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a requirement to develop a html prototype for my next project. While i was going through the old project files,
I noticed that css, js and images are inserted as below in a file.

Image Insertion:

Js Insertion

css Insertion

Here xxxx refers to company name

Please let me know,

1. For every insertion of css, have they created separate domain name like css1.xxxx.com etc.
2. What is an advantage of doing so

I did not understand this concept. Please explain
Posts: 24635
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You were at the company who had that idea, weren't you? Usually if you want to know why somebody did something, the best way to find out is to ask them.

Now, it's possible that their reasons were completely bogus. Sometimes people have weird ideas. Once you found out their reason, this site would be a sensible place to ask about that.

And it's also possible that you might get an answer like "Oh, the consultants who were in here four years ago told us to do that but they never said why" or "Oh, that was X's idea, he doesn't work here any more but we're stuck with it". Not all decisions are made for sound technical reasons. Or even for technical reasons.
Posts: 67279
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to add: I've never seen that done anywhere, and it certainly seems very very odd.

The only possible scenario I can think of is that this was a massive and heavily trafficked site where it made sense to serve the various pieces from different physical servers.
Posts: 15385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Short answer:
It is done for performance.

Browsers have a limit on the number of connections it can make to a single domain. This is especially important when you are dealing with IE6 who only has 2 connections to a domain. If you ever tried to communication with iframes/frames/popup windows/Ajax with a sub domain you know the browser gives an error because it sees it as a different domain. So by using different sub domains/cnames you get around the two connection restriction and get more connections!

For a real world example, look at google maps. They pull their images from multiple cnames. I think it is something like mt#.google.com where they grab the tiled images as you move the map around.

Do not run out and get all cname happy. You should not make each file have its own subdomain. There is a limit on the number of CNames that you should use on a single page. Performance drops or levels off at four or five depending on the browser and connection type. If you search the net, you can see people sat down and tested the performance with browsers and the number of CNames. It basically came down to the number of open connections allowed by the browser and the size of the tube [bandwidth]. You hit a point when too much of a good thing is bad. Tell that to a kid on Halloween as they eat 50 candy bars, their stomachs will not like them in the morning.

My personal real-life experience:
I actually landed a job by suggesting doing the cnames for static content, it chopped off 24 seconds off the load time in ie6 and about 16 seconds in firefox 1.5. Page in IE6 took over a minute and a half to load before I started my magic, got it down to under 20, wanted to reduce it more, but they did not want to make the drastic changes required. So I am that crazy consultant that came in and improves a site's performance! It is amazing what simple little changes [compression, caching, cnames, location of resources] can do to page load times.

It really makes sense after you see it work first hand. It is not all smoke and mirrors!

The first person to drink cow's milk. That started off as a dare from this tiny ad:
Enterprise-grade Excel API for Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!