tags:

views:

46

answers:

2
+1  Q: 

HTML CSS Inclusion

Hi,

Might be a silly question, just wanted to know do the following ways on including CSS have any impact on the server response time. If yes, which is the better method and how

Way 1 :

<link rel='stylesheet' href='css/some.css'/>

Way 2 :

<link rel='stylesheet' href='http://www.somesite.com/css/some.css'/&gt;
+4  A: 

No, your browser converts any URL into an absolute URL before making the request, so it won't make any difference.

pib
As a side note, you may see a performance increase if you're able to store your CSS on a seperate domain.
Sonny Boy
Yep, a lot of popular sites will put their static content (CSS, images, javascript, etc.) on a CDN and only server up dynamic content from their own servers. In fact, look at the source of this page, the static content is served up from http://sstatic.net
pib
A: 

Depends. If you want to have the same website to run in the dev, test as well as prod environments without changing code, you'd like to use relative paths. Instead of that you can also specify a <base> element so that you only need to specify the domain only once -if necessary dynamically using a server-side language.

Another thing to take into account when hardcoding the protocol (the http: part) is that you would like to use at least protocol-relative URL's when your website may switch between HTTP and HTTPS regulary. A CSS file which is hardcoded on http://example.com/style.css may cause security complaints in most webbrowsers about "unsafe content". In such case you'd like to use relative paths such as style.css or if you persist in using the full domain name, use //example.com/style.css instead. This by the way also applies on all other resources like Javascripts and (CSS) images.

BalusC