(Tips) Adding a JavaScript File to a Drupal Theme

Tips : Adding a JavaScript File to a Drupal Theme

Drupal comes with the excellent and very powerful jQuery JavaScript library. jQuery really reduces the learning curve when it comes to adding fancy JavaScript effects to a Drupal site.

In this mini-tutorial I will show you how you can add a theme-based JavaScript file to your site so you can start to leverage the power of jQuery in your projects.

Instructions

Drupal 6:
Drupal 6 already looks for a script.js file in the theme folder as explained in the handbook. If you don't need to know how to add extra JavaScript files then just create that file and you're done! It might be considered a best practice to follow the instructions below rather than relying on the built-in method. Thanks to longwave for pointing this out.

1. Create a file named scripts.js and place it in your theme folder.
2.Edit your theme's [theme-name].info file and add the following on a new line:

scripts[] = scripts.js

3. Important: Go to Administer > Site building > Themes (admin/build/themes) and resave the page to refresh the .info file cache.

| Read more..

Courtesy : Freestylesystems.co.uk