Support » Plugin: AnythingSlider for WordPress » [Plugin: AnythingSlider for WordPress] [AnythingSlider] Not work when JQuery in the footer (WP-plugi

  • In my template JQuery loads in the footer, it’s better for loading page faster.


    global $anythingSliderScripts;
    $anythingSliderScripts = “
    jQuery(function() {

    theme : ‘{$theme}’,
    expand : {$expand},
    resizeContents : {$resizeContents},
    vertical : {$vertical},
    showMultiple : {$showMultiple},
    easing : ‘{$easing}’,

    buildArrows : {$buildArrows},
    buildNavigation : {$buildNav},
    buildStartStop : {$startStopped},

    toggleArrows : {$toggleArrows},
    toggleControls : {$toggleControls},

    startText : ‘{$startText}’,
    stopText : ‘{$stopText}’,
    forwardText : ‘{$forwardText}’,
    backText : ‘{$backText}’,
    tooltipClass : ‘{$tooltipClass}’,

    enableArrows : {$enableArrows},
    enableNavigation : {$enableNav},
    enableStartStop : {$enablePlay},
    enableKeyboard : {$enableKeyboard},

    startPanel : ‘{$startPanel}’,
    changeBy : ‘{$changeBy}’,
    hashTags : {$hashTags},
    infiniteSlides : {$infiniteSlides},
    navigationFormatter : {$navFormat},

    autoPlay : {$autoPlay},
    autoPlayLocked : {$autoPlayLocked},
    autoPlayDelayed : {$autoPlayDelayed},
    pauseOnHover : {$pauseOnHover},
    stopAtEnd : {$stopAtEnd},
    playRtl : {$playRtl},

    delay : {$delay},
    resumeDelay : {$resumeDelay},
    animationTime : {$animation},
    delayBeforeAnimate : {$fadeTiming},

    clickForwardArrow : ‘{$clickForwardArrow}’,
    clickBackArrow : ‘{$clickBackArrow}’,
    clickControls : ‘{$clickControls}’,
    clickSlideshow : ‘{$clickSlideshow}’,

    resumeOnVideoEnd : {$video},
    addWmodeToObject : ‘{$addWmode}’


    if ( $fade !== ‘false’ ) {

    $anythingSliderScripts .= “
    jQuery(function() {
    ‘.panel’ : [ ‘fade’, ”, {$fadeTiming}, ‘{$easing}’ ]


    } wp_reset_query();

    return $output;

    do_action( “add_anything_slider_FX”, $id );
    do_action( “add_anything_slider_FX_{$id}”, $id );


    add_action(‘wp_footer’, ‘anythingSliderScripts’, 9);

    function anythingSliderScripts(){
    global $anythingSliderScripts;
    echo $anythingSliderScripts ;

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Jacob Dubail


    What’s your question?

    jQuery can load in the footer, but that code is dynamically generated and is inserted into the page wherever the shortcode is encountered.


    It’s not a question, I suggest you to add this code to your plugin, for people who download JavaScripts in the footer for faster page loading.

    I 2nd this idea! Sadly, however, I do think jQuery loading in the footer should be optional since so many plugins would break if this was by default. But the rest of the scripts should definitely load in the footer.

    For those looking for a way to do this, just open up jtd-anything-slider.php. Look for all the wp_enqueue_script lines, and right before the end of the line, after the version number which looks similar to this: 'x.x' where x is a number, add a comma and true.

    So, for example, here’s a line of code which places the anythingslider jQuery script in the head on line 34:

    wp_enqueue_script( 'jquery.anythingslider', JTD_INSERTJS . '/jquery.anythingslider.min.js', array( 'jquery' ), '1.7.26' );

    To force this script to go to the footer, add true to the end of the code like this:

    wp_enqueue_script( 'jquery.anythingslider', JTD_INSERTJS . '/jquery.anythingslider.min.js', array( 'jquery' ), '1.7.26', true );

    Hope this helps others!

    Plugin Author Jacob Dubail


    Hey guys,

    This was/is a priority for me. The problem I kept running into was that I dynamically generate the script that fires the slider, which happens at the same time that the slide markup is generated. I couldn’t figure out a way to throw that dynamic script into the footer, so had to leave jQuery in the header. Make sense?


    Sean Donovan


    You can force WP to put all the javascript in the footer, but this breaks the Anything Slider WP plugin because it inserts the jQuery into the middle of the page (as fixed by SergSlon above).

    remove_action(‘wp_head’, ‘wp_print_scripts’);
    remove_action(‘wp_head’, ‘wp_print_head_scripts’, 9);
    remove_action(‘wp_head’, ‘wp_enqueue_scripts’, 1);
    add_action(‘wp_footer’, ‘wp_print_scripts’, 5);
    add_action(‘wp_footer’, ‘wp_enqueue_scripts’, 5);
    add_action(‘wp_footer’, ‘wp_print_head_scripts’, 5);

    I would like the Anything slider to put it’s JS in the footer too.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: AnythingSlider for WordPress] [AnythingSlider] Not work when JQuery in the footer (WP-plugi’ is closed to new replies.