There are a ton of tutorials out there about how to include javascript and jQuery in WordPress. I probably read most of them as I was adapting my WordPress based CMS to use my newly gained jQuery skills. The theme writer’s approach to including javascript is to modify your theme’s functions.php file and call the wp_enqueue_script function to trigger when wp_print_scripts action fires. However, for the tweak happy folks like me, there’s actually an easier way that I stumbled upon reading the excellent wpengineer blog.
I was reading about contact forms at wpengineer and the code included the wp_enqueue_script call right in the template before the get_header() call. Brilliant! I had never read that about that technique. You don’t have to write conditional statements nor hook in within the functions.php file. This is especially handy if you use a premium theme. Premium themes usually have a functions.php file that includes a huge caveat not to modify it (for a lot of good reasons). An even better benefit to modifying the template is as your theme is updated, you don’t have to worry about carrying over custom edits.