JavaScript in Drupal

Last modified: January 16, 2009 - 18:16

Drupal provides methods for implementing JavaScript. Using these methods will help to keep your code clean and to ensure compatibility with the way other modules implement JavaScript.

A couple of simple principles guide Drupal's JavaScript approach:

  • All pages should be perfectly functional without scripts. JavaScript provides alternatives or supplements - not replacements - for standard elements.
  • No JavaScript is hard-coded into pages. Rather, actions are attached dynamically to page elements--and only if the needed Javascript support is present.

See also the JavaScript developer API in the API section of the handbook.

Note: this section is currently being overhauled. The numbered subsections are the new content added to date - more to come very soon! The non-numbered subsections are old content that needs to be incorporated, updated or removed.

 
 

Drupal is a registered trademark of Dries Buytaert.