WordPress.org

Ready to get started?Download WordPress

Forums

Genesis Responsive Slider
Change how resources are loaded to allow for defer loading (1 post)

  1. bassjobsen
    Member
    Posted 8 months ago #

    The genesis_responsive_slider_flexslider_params() function writes javascript direct to the source. This code depends on jQuery and should enqueued properly.

    Solution wrap the code including the document ready in a new file (use variables for the parameters). Set variable with wp_localize_script when enqueueing. Enqueue in genesis_responsive_slider_scripts():

    /**
     * Load the script files
     */
    function genesis_responsive_slider_scripts() {
    
    	/** easySlider JavaScript code */
    	wp_enqueue_script( 'flexslider', plugins_url('js/jquery.flexslider.js', __FILE__), array( 'jquery' ), GENESIS_RESPONSIVE_SLIDER_VERSION, TRUE );
    
    	/** set parameters for display **/
    
    	$options = array();
    	$options['timer'] = ( int ) genesis_get_responsive_slider_option( 'slideshow_timer' );
    	$options['duration'] = ( int ) genesis_get_responsive_slider_option( 'slideshow_delay' );
    	$options['effect'] = genesis_get_responsive_slider_option( 'slideshow_effect' );
    	$options['controlnav'] = genesis_get_responsive_slider_option( 'slideshow_pager' );
    	$options['directionnav'] = genesis_get_responsive_slider_option( 'slideshow_arrows' );
    
    	 wp_register_script( 'flexslider_display', plugin_dir_url( __FILE__ ).'flexslider_display.js', array( 'jquery' ), '20131108' );
    	 wp_enqueue_script( 'flexslider_display' );
    	 wp_localize_script('flexslider_display', 'flexslider_display_options',$options);
    
    }

    Remove genesis_responsive_slider_flexslider_params and calls to genesis_responsive_slider_flexslider_params. (add_action).

    with flexslider_display.js:

    jQuery(document).ready(function($) {
    				$(".flexslider").flexslider({
    					controlsContainer: "#genesis-responsive-slider",
    					animation: esc_js( flexslider_display_options.effect ),
    					directionNav: flexslider_display_options.directionnav,
    					controlNav: flexslider_display_options.controlnav,
    					animationDuration: flexslider_display_options.duration,
    					slideshowSpeed: flexslider_display_options.timer
    			    });
    });

    http://wordpress.org/plugins/genesis-responsive-slider/

Reply

You must log in to post.

About this Plugin

About this Topic