This question already has an answer here:

I'm developing a mobile site and the template I'm using is based off of Jquery Mobile.

In the header.php file, the template I am using is making calls to CDN javascript files:

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-
1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>

Since I'm basically pulling in the JavaScript from those URLS and it's not actually some .js file in a folder on my web server - how would I go about adding additional javascript code? Do I add it to my header.php? Get a special plugin that'll allow me to add additional javascript? The template doesn't give my any option to add additional code. So, not sure where the code would actually go...

Thanks in advance

marked as duplicate by s_ha_dum, brasofilo, Chris_O, fuxia Feb 7 '13 at 21:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Technically yes, you can add those lines to your header.php file just after the wp_head() function and it'll load the jQuery from a remote source, just like it was on your local machine.

If you want to do it properly, take a look at http://codex.wordpress.org/Function_Reference/wp_enqueue_script which will allow you to add it through the wp_head() hook, which will check to make sure the script hasn't already been loaded.

  • Thank you Christopher...this is perfect. This will work for me. – steve02a Feb 7 '13 at 23:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.