Javascript

The Secret to drupal_add_js

drupal_add_js() doesn't add javascript or jquery to your Drupal page? Let's take a look at why, and how to fix it.

Sometimes we need javascript or jquery in our Drupal page. If the script needs to appear on every page, we could just add it to our page template, but what if we want it only on one page?

We could create a page template for the page on which we want it. If the requirement is static and small, that is a way to do it, though putting the script directly in the template is not the best-practices way to do it, for several reasons.

Subscribe to Javascript