Host assets on different domains Oct27 '07
According to this Sitepoint article on web site optimization, it's wise to host your web site assets (images, JavaScript, CSS, etc.) on different domains, in order to increase the number of parallel downloads, thus decreasing overall load time, and making your visitors happy.
Ideally, you should create sub-domains for your assets. For this site, I've created the domain assets.matthom.com, and made the home folder point to my existing site files. This is an important step, as it eliminates any need to duplicate your files into other domain directories.
With Dreamhost, this is easy:

Notice where it says "Specify your web directory", I've included the path to the directory for this domain (matthom.com):
/home/username/matthom.com/
So it's almost like a virtual domain, in that it's a separate entity, yet it points to an existing folder. To see this in action, simply visit the domain itself: http://assets.matthom.com. It's a mirror image.
Regardless, the browser will treat it as a separate domain, and proceed to download my assets at the same time my main content is downloaded. (Browsers can only download two assets per domain, at a time.)
To decide which assets go to which domain, it's wise to consider your content, vs. your presentation and behavior. In other words, your "content images" (images that reside within an article body) should remain on one domain, and your CSS (presentational images, background, etc.) and JavaScript (behavior) should reside on another domain. This forms a nice, semantic separation.
To make these changes within your markup, just reference the sub-domain, as opposed to the main domain:
<script type="text/javascript" src="http://matthom.com/javascript/main.js"></script>
The above line would become:
<script type="text/javascript" src="http://assets.matthom.com/javascript/main.js"></script>
You don't have to move or copy any files at all, as long as your host allows you to create sub-domains which point to other directories.
Categories: Browsers
, Domains
, Dreamhost
, Tips
, Tutorials ![]()
Add Feedback (view all)
Leave feedback
matthom
is published and produced by Matt Thommes - an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from Chicago.
Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us.
Similar Entries
- Dreamhost Google Apps for new domains (182 recent visits)
- Consider alternatives to personal domains (12 recent visits)
Stats
3 unique visits since August 2008
Recent Referrers (click)
- what are the different domains in http
- assets
- http://matthom.com/archives/ca
- what are the different domains in http
- assets
- http://matthom.com/archives/ca
- what are the different domains in http
- assets
- http://matthom.com/archives/ca
- what are the different domains in http
- assets
- http://matthom.com/archives/ca
- what are the different domains in http
- assets
- http://matthom.com/archives/ca