Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

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

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #43121
    divinehammer
    Participant

    I’m adding [this responsive nav script](http://media02.hongkiat.com/responsive-web-nav/demo/index.html “”) to my theme. It requires putting this into the code:

    http://codepen.io/anon/pen/ACwjc

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

    wp_register_script( ‘jquery’, ‘http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js’, 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?

    #126819
    divinehammer
    Participant

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

    http://codepen.io/anon/pen/lnpJE

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

    #126833
    JohnMotylJr
    Participant

    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_deregister_script('jquery');
    wp_register_script('jquery', "http" . ($_SERVER == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js", false, null);
    wp_enqueue_script('jquery');
    }

    Here is the article.

    #126875
    divinehammer
    Participant

    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 –

    ``

    #126901
    divinehammer
    Participant

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

    http://d.pr/i/VwBp

    And the head stuff looks like this –

    http://d.pr/i/owzq

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.