Zaje
Zaje

Reputation: 2309

HTML CSS Inclusion

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'/>

Upvotes: 2

Views: 1072

Answers (2)

BalusC
BalusC

Reputation: 1108732

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.

Upvotes: 0

pib
pib

Reputation: 3313

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

Upvotes: 6

Related Questions