Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

link rel="script" usage

I am reading through the XHTML 1.0 Strict Doctype and found out that there's a value of "script" for the rel attribute on the link element.

<link rel="script" href="..." />

I tried using this tag to link external JS files, but Safari does not even load the file. So what can the tag be used for?

Update:

After rereading the DTD, it doesn't exactly list out valid values for the rel attribute. The 'script' value appears only as an example on a comment. Thus, this may or may not be implemented in all browser.

like image 986
Adrian Godong Avatar asked Feb 27 '23 07:02

Adrian Godong


2 Answers

The link element is there to convey relationship information between the page being viewed and the content of the element.

From the spec:

Although LINK has no content, it conveys relationship information that may be rendered by user agents in a variety of ways

So, informational only.

like image 111
Oded Avatar answered Mar 11 '23 15:03

Oded


There is not only a "script" value, "rel" can contain any valid attribute content. The questions are:

  1. Which values have meanings defined (usually via specifications like XHTML 1.0)?
  2. Which browsers support those?

Obviously, the W3C wanted scripts to be includable like stylesheets (<link rel="Stylesheets" …>), but did not mention it in the prosa sections of the spec, only in the DTD comments. You find it in the HTML 4.01 strict DTD as well (XHTML 1.0 is just a reformulation of HTML 4.01 in XML). Strangely, it is neither not mentioned in the corresponding link type section nor in the script section. It could be an artifact of an idea which was rejected later.

This brings us to the answer to question 2. It is not properly implemented in browsers, at least in Safari (you mentioned it yourself). Therefore, you should not use it, because it will not work cross-browser. You can use it as a hack (to include scripts which will not be loaded by Safari), but this is not safe, because you cannot tell if a later version of Safari changes the behaviour.

like image 42
GodsBoss Avatar answered Mar 11 '23 15:03

GodsBoss