WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use the default TwentyTen theme and I have made a child theme with some CSS adjustments, and that's pretty much it.

Now I'd like to do two things

  • Make the theme load the latest jQuery, and to load it using the Google CDN.
  • Add a javascript file which would be loaded on every page.

What's the best way to do that? I'm a total WordPress newb, so don't really know my way around.

share|improve this question
up vote 1 down vote accepted

Here you go.

add_action('init', 'register_custom_jquery');
function register_custom_jquery() {


add_action('wp_enqueue_scripts', 'add_js_to_page');
function add_js_to_page() {
    wp_enqueue_script( 'jquery' );

    wp_enqueue_script( 'my-custom-script' );
share|improve this answer
where do I do this? – Svish May 28 '11 at 22:54
In your theme's functions.php – Hameedullah Khan May 28 '11 at 23:52
Aha. Could you just show how you would enqueue a custom script as well? Just want to be sure I get it right... – Svish May 29 '11 at 2:27
I have updated my answer. – Hameedullah Khan May 29 '11 at 4:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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