This presentation is a top level overview of how to work with JavaScript in drupal. This includes drupal specific techniques, integration between the front end and back end, and JS aggregation and special features.
2. Matt Farina
Developing for web since 1996
Coded In Over 10 Languages
Developer at Tree House Agency
Drupal and jQuery Developer
I Used To Build Military Tanks
3. A Little History
jQuery chosen for drupal core before
release of jQuery 1.0
jQuery 1.0.4 shipped with drupal 5
Drupal 5 used jQuery to spruce up
interface
jQuery 1.2.3 shipped with Drupal 6
Drupal 6 translations, themes, libraries
Currently jQuery 1.2.6 in Drupal 6
Drupal 7 to ship with latest version of
jQuery (current Dev is 1.3).
5. Printing Scripts In Your Theme
In your page.tpl.php file(s) include:
<?php print $scripts; ?>
6. The Default script.js file
/sites/all/themes/mytheme
/sites/all/themes/mytheme/
mytheme.info
/sites/all/themes/mytheme/script.js
by default script.js will be included
7. Defining Scripts in .info
In you mytheme.info file:
scripts[] = ascript.js
scripts[] = jquery.plugin.js
scripts[] = bscript.js
21. Translating Stuff
!variable: inserted as is
@variable: escape plain text to HTML
(Drupal.checkPlain)
%variable: escape text and theme as a
placeholder for user-submitted