Forums

3.4 loads jquery last, not first anymore - breaks all plugins (14 posts)

  1. sccr410
    Member
    Posted 11 months ago #

    Just upgraded to 3.4 and every site I have done it on thus far all JS is broken. The cause is that jquery, when loaded via wp_enqueue_script() gets loaded last when it needs to get loaded first. So all the other jQuery files that require it be loaded first fail and nothing works anymore.

  2. stevej.in
    Member
    Posted 11 months ago #

    I'm also experiencing the same problem, and I hope someone is able to find a solution to this or this issue gets resolved soon!

  3. dehilster
    Member
    Posted 11 months ago #

    Temporary fix:

    Include this in the header.php file in your theme:

    <script type='text/javascript' src='http://www.xxxx.yyy/wp-includes/js/jquery/jquery.js?ver=1.7.1'></script>

  4. stevej.in
    Member
    Posted 11 months ago #

    dehilster, thanks for your help on the temporary fix!

  5. saedecode
    Member
    Posted 11 months ago #

    here's another fix. Add these codes on your plugin.

    add_action('wp_head', 'load_scripts');
    add_action('admin_head', 'load_scripts');

    function load_scripts(){
    wp_enqueue_script('jquery');
    ...
    }

    From http://webdev-tuts.com/wordpress/jquery-is-not-defined-in-wordpress-3-4.html

  6. jim.hubbard
    Member
    Posted 11 months ago #

    Where do we include <script type='text/javascript' src='http://www.xxxx.yyy/wp-includes/js/jquery/jquery.js?ver=1.7.1'></script>?

    Is there a certain place in the header.php file that it should go?

  7. valuser
    Member
    Posted 11 months ago #

    dehilster, thanks for your help . works for me just before <?php wp_head(); ?>

    Potential downsides ?????

  8. The potential downside it that the wp_enqueue_script will not know you've already loaded jquery.js and you may run into problems.

    I've not tested it myself, but have you just tried the code from the Codex article?

    http://codex.wordpress.org/Function_Reference/wp_enqueue_script

    <?php
    function my_scripts_method() {
        wp_deregister_script( 'jquery' );
        wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js');
        wp_enqueue_script( 'jquery' );
    }    
    
    add_action('wp_enqueue_scripts', 'my_scripts_method');
    ?>

    See that add_action()? It takes takes a third parameter called $priority. The default is 10 but if you make it lower, such as 5, then it should queue up first.

    add_action( 'wp_enqueue_scripts', 'my_scripts_method' , 5 );

    http://codex.wordpress.org/Function_Reference/add_action

    Give that a try. If it works and it puts jquery in place first, then you'll be on the road to wp_enqueue_scripts Nirvana...

  9. valuser
    Member
    Posted 11 months ago #

    @Jan Dembowski. Many thanks.

    Have not tried anything else.

    Not a coder.

    The safe and recommended method of adding JavaScript to a WordPress generated page ...................

    Somebody like me actually needs to be hand-held and told " .... and then you place it in the (say) functions.php file or (say) the header.php file or...etc etc.

    Basically I haven't got a clue but can reasonably follow instructions and copy & paste!!

    Anyway I would love to know where best to put the snippet above ?

    Coming to this via part of a login plugin becoming unresponsive in 3.4

    http://wordpress.org/support/topic/plugin-registration-login-wp-34-login-ajax-not-working?replies=2

  10. valuser
    Member
    Posted 11 months ago #

    ok.
    tried the above in functions.php file - did not work
    tried the above in header.php file - did not work

    For the time being will have to stay with <script type='text/javascript' src='http://www.xxxx.yyy/wp-includes/js/jquery/jquery.js?ver=1.7.2'></script>

    from @ dehilster above -----> in the header.php file of each theme.

  11. jim.hubbard
    Member
    Posted 11 months ago #

    Jan's idea completely broke my site. The site did not show at all when using the wp_enqueue_scripts hack.

    I've tried placing

    <script type='text/javascript' src='http://www.*******.net/wp-includes/js/jquery/jquery.js?ver=1.7.2'></script>

    after the <head> tag and tried it before the </head> tag and neither of them do anything to fix the issues I am having with 3.4.

  12. esmi
    Theme Diva & Forum Moderator
    Posted 11 months ago #

    wp_enqueue_scripts() isn't a hack. It's the correct way to add js scripts to your site. If you have a problem using it, please post a new topic.

  13. clarkb5
    Member
    Posted 11 months ago #

    I updated to WordPress 3.4 using the latest version of Revelation Theme by Celta Themes.

    I used to have a working JS powered Content Slider (main banner image on home page) but now it's not working.

    I've tried the wp_enqueue_scripts() patch someone described above, but it isn't working. I even set the priority to 1, so that it would load first, but it's not changing anything. I could just embed all the .js includes in the header of my theme, but I wanted to stay away from that solution if I knew there was another WP fix someone could help me with.

    Any ideas, guys?

    I'm also in contact with the Theme author to try and see what he has to say about the matter.

    --Bethany

  14. newplayer
    Member
    Posted 11 months ago #

    in wp_enqueue_script I use the $deps paramter, and it's worked fine for me:

    wp_enqueue_script("jquery");
    wp_enqueue_script("bxSlider",get_template_directory_uri()."/js/jquery.bxSlider.min.js",array("jquery"),"3.0");

Reply

You must log in to post.

About this Topic

Tags