[thelist] do not use the javascript: link protocol - why? (was: collapsible elements without using IDs)

liorean liorean at gmail.com
Tue Dec 7 18:41:50 CST 2004


On Tue, 07 Dec 2004 10:13:12 -0400, Sarah Sweeney
<mr.sanders at designshift.com> wrote:
>  > P.S: Never, under _any_ circumstances use javascript: as a link protocol. It is a bad habit that MUST die.
> I think I know why you are (so adamantly) advocating this, but I'm not 100% certain. Can you fill us in, please?

Well, there are a number of reasons from usability, accessibility,
optimisation and standards comformance perspectives.

Usability:
    Something not often mentioned but one of the most important
factors in my view, is that the 'javascript:' pseudo-URI destroys
several layers of usability features. E.g:
- The link does in most cases only work when simply clicked, it
generally no longer works:
  * When bookmarked
  * When users chose 'open in new window' or 'open in new tab'
  * When users to copy the link to clipboard for offline referencing
- Browsers that handle internal and external links different no longer
knows what kind of link it is

Accessibility:
Of course, it's a question whether some users are able to use the
resource at all...
- The link does not work in JavaScript disabled environments such as
many corporate environments
- The link does no longer work in browsers that fail at supporting
JavaScript, such as many mobile phone and PDA browsers

Optimisation:
There are different kinds of optimisations, but some common ones are
size and search engine optimisations.
- Links using 'javascript:' pseudo-URIs generally don't get spidered
by search engines.
- SCRIPT bodies in the HEAD or early in the BODY are generally
severely downgrading the relevancy of your page for any search terms
apåpropriate for the content, in the views of the search engines.
- If embedded in the page, the script adds to the size of the page
that the user has to download. That means that you have to pay for
larger data transfer ratios, and the user has to wait longer for the
page to download
- Scripts that are scattered through the site take more time to
upgrade and more work to maintain than if you instead moved all
scripting to separate files, leaving the HTML scriptless.

Standards conformance:
There are a lot of web standards that you can have a look at. There's
also a level of conformance that could be called conforming to the
spirit of standards, as opposed to just the word of them.
- There is no 'javascript' URI scheme registred, so it's not a valid
resource identifier
- There are no specific security or semantics formally defined for the
'javascript' pseudo-URIs
- In the spirit of the semantic web, behavior as provided by scripting
should not be part of the document structure and/or content unless the
behavior can be considered to be the actual content provided
-- 
David "liorean" Andersson
<uri:http://liorean.web-graphics.com/>


More information about the thelist mailing list