• Resolved Todd

    (@track23)


    WordPress’s bundled jQuery is severely out of date. I have tried to update jQuery to the latest version using these three plugins:
    https://ww.wp.xz.cn/plugins/jquery-manager/
    https://ww.wp.xz.cn/plugins/jquery-updater/
    https://ww.wp.xz.cn/plugins/version-control-for-jquery/

    After installing and activating each of the plugins I get the same error:

    $(...).flexslider is not a function

    With a couple of those plugins you can choose a specific version of jQuery and even when I choose the same version that’s bundled with WP I get the error, so my guess is that it has to do with deferred loading or some other timing issue. However everything looks legit to me (see below), so I’m at a loss for a solution.

    jquery.min.js loads at line 55:

    <script type='text/javascript' src='https://code.jquery.com/jquery-3.3.1.min.js?ver=3.3.1' defer='defer'></script>

    flexslider.min.js loads at line 597:

    <script type='text/javascript' src='/wp-content/plugins/ml-slider/assets/sliders/flexslider/jquery.flexslider.min.js?ver=3.14.0' defer='defer'></script>

    slider code begins on line 598:

    <script type='text/javascript'>
    var metaslider_4473 = function($) {$('#metaslider_4473').addClass('flexslider');
                $('#metaslider_4473').flexslider({ 
                    slideshowSpeed:6000,
                    animation:"fade",
                    controlNav:true,
                    directionNav:true,
                    pauseOnHover:true,
                    direction:"horizontal",
                    reverse:false,
                    animationSpeed:600,
                    prevText:"<",
                    nextText:">",
                    fadeFirstSlide:true,
                    slideshow:true
                });
                $(document).trigger('metaslider/initialized', '#metaslider_4473');
            };
            var timer_metaslider_4473 = function() {
                var slider = !window.jQuery ? window.setTimeout(timer_metaslider_4473, 100) : !jQuery.isReady ? window.setTimeout(timer_metaslider_4473, 1) : metaslider_4473(window.jQuery);
            };
            timer_metaslider_4473();
    </script>

    Has the plugin been tested with the jQuery update plugins listed? Is there another method I could use to upgrade jQuery that would work with the ML Slider plugin?

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @track23

    If you do not defer jQuery does it work?

    Thread Starter Todd

    (@track23)

    Thanks for your response.

    I can’t figure out a way to do that using the plugins I referenced. This one appears to have the option, but it doesn’t work.

    Hi @track23

    You’ll have to contact them about this most likely. You could just unregister and register jQuery without a plugin though (lots of howtos on Google about this). If you don’t have a specific need for a newer version of jQuery though I would just leave it alone.

    Thread Starter Todd

    (@track23)

    I removed the plugins and swapped out jquery (and jquery-migrate) manually using
    wp_deregister_script('jquery');
    and
    wp_enqueue_script('jquery', 'https://code.jquery.com/jquery-3.4.1.min.js', array(), null, true);

    It still didn’t work at first, but then I moved the scripts to the footer using the Genesis framework’s genesis_after_footer hook. I don’t know how, but that seems to have done the trick!

    Here’s my final code for anyone else who may be using the Genesis framework and having trouble:

    
    add_action( 'wp_enqueue_scripts', 'custom_remove_jquery' );
    function custom_remove_jquery() {
    	wp_deregister_script('jquery');
    	wp_deregister_script('jquery-migrate');
    }
    add_action('genesis_after_footer', 'custom_jquery_in_footer');
    function custom_jquery_in_footer() {
    	wp_register_script('jquery', 'https://code.jquery.com/jquery-3.4.1.min.js', array(), null, true);
    	wp_enqueue_script('jquery');
    
    	wp_register_script('jquery-migrate', 'https://code.jquery.com/jquery-migrate-3.1.0.min.js', array( 'jquery' ), null, true);
    	wp_enqueue_script('jquery-migrate');
    }
    

    Thanks for your help.

    • This reply was modified 6 years, 7 months ago by Todd.

    Hi @track23

    Thanks for the follow up and glad to hear it’s working with jQuery 3! Let me know if you have any more issues.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘ML Slider doesn’t work with jQuery update plugins’ is closed to new replies.