WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] jQuery not registered in 3.3 (7 posts)

  1. Peter Wooster
    Member
    Posted 2 years ago #

    Hi I use the following code to load a full version of jQuery:

    if( !is_admin()){
       wp_deregister_script('jquery');
       wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"), false, '1.7.0');
       wp_enqueue_script('jquery');
    }

    It worked well until I upgraded to 3.3 and now jQuery is not being included in my pages, so none of my Javascript is working.

    /peter

  2. Change that to 1.7.1 jquery, or try the "Use Google Libraries" plugin.

  3. Peter Wooster
    Member
    Posted 2 years ago #

    Changing it to 1.7.1 did not work. Both the 1.7.0 and 1.7.1 don't get loaded at all, the <script... does not appear in the source. I've worked around this for the moment by using:

    if( !is_admin()){
       wp_deregister_script('jquery');
    }

    in my functions.php and

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

    in my header.php. I know it's a nasty kludge, but this is a production site issue.

    /peter

  4. shirazdrum
    Member
    Posted 2 years ago #

    Ipstenu,

    I don't recall ever having to use the version number when calling the WordPress shipped scripts. Has anything changed? The function he is using is to call the CDN copy of jQuery, not the WordPress.

    Pkwooster,

    Your function is correct, regardless of what version you are calling. You could call for 1.4 and even that wouldn't make a bit of difference. Make sure you have no conflict between other scripts loading the same version. Deactivate all your plugins and start testing. Also, use no-conflict wrappers if your scripts use $ instead of full name.

    If nothing works, download the library and call it on your own server.

  5. Peter Wooster
    Member
    Posted 2 years ago #

    The kludge of deregistering the WordPress jQuery and loading it directly from the header file works. There is nothing wrong with either version on the Google CDN. And I always use the full jQuery name in my own code. The problem appears to be in the registration process.

  6. Peter Wooster
    Member
    Posted 2 years ago #

    Sorry, this problem was not related to 3.3, I'd moved the wp_head call in the header file. That caused the jQuery to be included too late. It appears that js that uses enqueued libraries must be included after the wp_head call.

    Thanks for all the very timely help. /peter

  7. shirazdrum - WordPress itself is using 1.7.1 and while normally you're fine using a newer version, using an older one could do weird things. Since registration is handed by the backend of WP, it's more important IMO for that to match up.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.