The easiest way to do this is actually a combination of wp_enqueue_script
and the footer actions that Saif and v0idless already referenced. I frequently use jQuery in my themes and plugins, but I put all of the other scripts in the footer as well.
The best way to actually queue things up would be this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function myscript() { ?> <script type="text/javascript"> if ( undefined !== window.jQuery ) { // script dependent on jQuery } </script> <?php } add_action( 'wp_footer', 'myscript' ); function myscript_jquery() { wp_enqueue_script( 'jquery' ); } add_action( 'wp_head' , 'myscript_jquery' ); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.