Get a free trial // Grow your CSS skills // Land your dream job

why does my theme need jQuery (twice) to work?

  • # March 3, 2013 at 10:42 pm

    I’m adding [this responsive nav script]( “”) to my theme. It requires putting this into the code:

    But I’d prefer to stick the jQuery link in functions.php, like this –

    wp_register_script( ‘jquery’, ‘’, null, ‘1.7.2’, false);

    But when I do that, the navigation no longer works. If I have links to the Google ajax libraries in both places it works fine. Why does it matter where I put the link?

    # March 3, 2013 at 10:44 pm

    To clarify, this is what’s in the header:

    If I remove the second reference to the Google ajax library, the navigation fails.

    # March 4, 2013 at 4:19 am

    Im assuming that you are using wordpress. Chris Coyier posted a nice little function to include inside your functions.php.

    This is the one i use and never have any problems:

    if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
    function my_jquery_enqueue() {
    wp_register_script('jquery', "http" . ($_SERVER == 443 ? "s" : "") . "://", false, null);

    Here is the article.

    # March 4, 2013 at 1:17 pm

    Thanks John. For some reason that doesn’t fix it.

    This code is what functions.php generates, but doesn’t help the nav work –


    Hard-coding this is the only thing that works –


    # March 4, 2013 at 3:03 pm

    where is your wp_head(); function located? Try moving that to just before the closing head element if it’s not already there. WP loads up a ton of stuff, sometimes extra junk, with that one function.

    # March 4, 2013 at 3:05 pm

    Do you have a live site? Would make it easier to see what’s going on.

    # March 4, 2013 at 3:10 pm

    I’m developing this theme locally, but my functions.php section looks like this –

    And the head stuff looks like this –

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed