• Before wp_enqueue_script the Ideal or Unslider JS files I suggest checking that you are on the front page and the slider is enabled.

    Here is a suggested patch for function/modailty-functions.php

    --- functions/modality-functions.orig.php	2016-02-25 18:45:20.000000000 +0000
    +++ functions/modality-functions.php	2016-07-10 10:08:13.501598200 +0100
    @@ -120,9 +120,16 @@
     	wp_enqueue_script('custom', get_template_directory_uri() . '/js/custom.js', array( 'jquery' ),'', true);
     	wp_enqueue_script('imgLiquid', get_template_directory_uri() . '/js/imgLiquid.js', array( 'jquery' ),'', false);
     	wp_enqueue_script('modernizr', get_template_directory_uri() . '/js/modernizr.js', array( 'jquery' ),'', false);
    -	wp_enqueue_script( 'unslider', get_template_directory_uri() . '/js/unslider.js', array( 'jquery' ),'', true);
    -	wp_enqueue_script( 'flexslider', get_template_directory_uri() . '/js/jquery.flexslider.js', array( 'jquery' ),'', true);
    -	wp_enqueue_script( 'ideal-image-slider', get_template_directory_uri() . '/js/ideal-image-slider.js', array(), '20160115', true );
    +    wp_enqueue_script( 'flexslider', get_template_directory_uri() . '/js/jquery.flexslider.js', array( 'jquery' ),'', true);
    +    /* Load correct slider JS files on front page if slider enabled. */
    +    if (is_front_page() && $modality_theme_options['image_slider_on'] != '1') {
    +        if ($modality_theme_options['default_image_slider'] == 'ideal') {
    +            wp_enqueue_script( 'ideal-image-slider', get_template_directory_uri() . '/js/ideal-image-slider.js', array(), '20160115', true );
    +        }
    +        else {
    +            wp_enqueue_script( 'unslider', get_template_directory_uri() . '/js/unslider.js', array( 'jquery' ),'', true);
    +        }
    +    }
     	if ($modality_theme_options['captions_on'] == '1') {
     		if (is_home() && ! is_paged()) {
     			wp_enqueue_script( 'iis-captions', get_template_directory_uri() . '/js/iis-captions.js', array(), '20160116', true );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Do not load slider JS unless slider enabled’ is closed to new replies.