Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are absolute href's OK to use on production sites?

Because of some apache rewrite rules in a project I'm working on, it's convenient to make href's and links in general absolute, because that assures that the browser will find the file behind that link, no matter what the URL is.

Example:

<img src="http://localhost/project/gfx/abc.jpg"></img>

instead of

<img src="gfx/abc.jpg"></img>

Would the former be slower than the latter, or in any way not as good?

It's not like I think of this as optimization; I guess I will use the absolute ones anyways (unless there's a really good reason not to do), but I'm interested in knowing whether using absolute URL's are OK or not.

Note that this will apply to all links/paths (hyperlinks, css and javascript includes, AJAX-calls etc.)

like image 672
Yngve Sneen Lindal Avatar asked Dec 19 '25 03:12

Yngve Sneen Lindal


1 Answers

It won't make a bit of difference. You might prefer to do this though:

<img src="/project/gfx/abc.jpg" />

The browser will figure out the domain for you.

like image 146
Samir Talwar Avatar answered Dec 20 '25 18:12

Samir Talwar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!