You are here:

  1. Manual
  2. Development
  3. Client-side script and DOM
  4. Optional nature

Client-side script and DOM: The optional nature of client-side scripts

Do not use client-side script for essential functionality on web pages, unless the lack of support for these scripts is sufficiently compensated by HTML alternatives and/or server-side script.

Guideline R-pd.14.1

Some visitors use browsers that have limited or no support for client-side script or they have disabled client-side script support. It could be an old version of a browser, or a very new one, like the browsers on mobile telephones and PDAs. Visitors may also have reasons to disable support, for instance for security reasons.

“Ensure that pages are usable when scripts, applets, or other programmatic objects are turned off or not supported. If this is not possible, provide equivalent information on an alternative accessible page.”

Even if the percentage of potential visitors without client-side scripts is low, web developers should not ignore this issue. The recommendations below can help web developers keep this.

Progressive enhancement of functionality

Essential functionality (for instance, form validation) can be controlled by means of client-side scripting, but it will fail if support for this is lacking. Web developers can compensate this situation by progressive enhancement.

If support for client-side scripts is lacking, the site will revert to HTML alternatives or server-side scripts.

An alternative to a client-side script does not necessarily have to achieve the same dynamic or visual effect as to script itself. Something counts as an alternative if the visitor is capable of achieving the purpose of the client-side script without having support for this script. Such a purpose could be checking and validation the data entered on a contact form, or navigating the website. At most, the lack of client-side scripts means that it is more difficult for the visitor to achieve these purposes.

HTML alternatives to client-side scripts

Content to be displayed as an alternative for client-side scripts can be included in the noscript element. However, it is often better to view client-side scripts as an extension of basic HTML functionality rather than an alternative. Read more

Server-side scripts as an alternative

Client-side scripts as a supplement to basic functionality, created by server-side scripts. Read more

No alternatives needed for client-side scripts

Not all client-side script applications require a no-script alternative; the visitor can do without many applications, as long as he can use the page.

An example is a menu on the page enabling the visitor to control the font size. It is possible to compensate this with a server-side script, but the web developer can also assume that browsers have a function of their own to scale the font size on pages to meet the user's preference. Visitors lacking client-side script support have to rely on this standard function.

Unobtrusive Javascript

The technique to completely separate the use of client-side scripts (in this case JavaScript) from – for instance – HTML is called ‘unobtrusive Javascript’. Whereas using CSS one implies the separation of (visual) presentation and content/structure, unobtrusive Javascript separates behaviour from content/structure. This makes it possible to individually create, modify or remove content/structure, visual presentation or behaviour. Thus, unobtrusive Javascript can be seen as one of the building blocks in the progressive enhancement principle.

Links en references

Contents: Client-side script and DOM

  1. Introduction
  2. The optional nature of client-side scripts
    1. HTML alternatives for client-side scripts
    2. Server-side scripts as an alternative
  3. Document Object Model


Web Guidelines version 1.3, November 2007.