• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Only load Genesis Responsive Slider resources on pages that use them

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Only load Genesis Responsive Slider resources on pages that use them

This topic is: not resolved

Tagged: genesis responsive slider, prevent loading scripts, slider resources

  • This topic has 7 replies, 2 voices, and was last updated 8 years, 5 months ago by Sridhar Katakam.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • January 12, 2017 at 7:13 pm #199304
    joycegrace
    Participant

    Hi there,
    I'm using Genesis responsive slider.

    I only need the slider to load on the home page.

    Does anyone know of a copy/paste code snippet to be able to stop the plugin's resources (js & CSS) from loading on every page of a site it's installed on? Such as by naming IDs or page slugs for it to be loaded on?

    I'm not much of a coder and also am not sure how to find the naming system to use by following instructions from other code snippets online that do this for other plugins.

    For example, I use the code below in functions.php to remove Contact Form 7 scripts from pages not using them:

    /**
     * Remove Contact Form 7 scripts + styles unless we're on the contact page
     * 
     */
    add_action( 'wp_enqueue_scripts', 'ac_remove_cf7_scripts' );
     
    function ac_remove_cf7_scripts() {
    	if ( !is_page('id-or-slug-goes-here') ) {
    		wp_deregister_style( 'contact-form-7' );
    		wp_deregister_script( 'contact-form-7' );
    	}
    }

    How can I achieve that with the Genesis responsive slider? I don't know what to replace "contact-form-7" with above. Or if the above would work...

    Your help would be very much appreciated.


    Find me at Joyce Grace (http://www.joycegrace.ca)

    January 12, 2017 at 11:33 pm #199314
    Sridhar Katakam
    Participant

    Hi Joyce,

    Follow https://sridharkatakam.com/prevent-genesis-responsive-sliders-css-js-files-loading-sitewide/


    Genesis Tutorials | Follow me on Twitter

    January 13, 2017 at 12:16 am #199315
    joycegrace
    Participant

    Hi Sridhar, thank you so much for your help.

    However, this does not seem to work for me. I also tried is_home()and if ( is_front_page() && is_home() ) from conditional tags instructions.

    When I view the source of a page that does not have the slider on it, I see this:

    <style type="text/css">.slide-excerpt { width: 0%; }
    			.slide-excerpt { bottom: 0; }
    			.slide-excerpt { right: 0; }
    			.flexslider { max-width: 1080px; max-height: 330px; }
    			.slide-image { max-height: 330px; }</style>

    And this

    <script type='text/javascript'>jQuery(document).ready(function($) {$(".flexslider").flexslider({controlsContainer: "#genesis-responsive-slider",animation: "slide",directionNav: 1,controlNav: 0,animationDuration: 2000,slideshowSpeed: 8000 }); });</script>

    I also tried an icognito window and cleared cache from using Autoptimize (and unchecked to optimize css and js in those plugin settings).

    Am I doing something wrong?

    E.g. view-source:http://www.executivesuite.ca/hot-desks-hourly-boardroom-vancouver/

    Your code is currently in my functions.php file on the above site.

    Same conversation happening here: https://wordpress.org/support/topic/only-load-genesis-responsive-slider-resources-on-pages-that-use-them/#post-8649561


    Find me at Joyce Grace (http://www.joycegrace.ca)

    January 13, 2017 at 12:22 am #199316
    Sridhar Katakam
    Participant

    You aren't doing anything wrong.

    Those two blocks of code can not be removed w/ the code from my tutorial. You may want to post in the plugin's support forum for help in getting rid of those.

    Adding the code from my tutorial does remove calls to plugin's style.css and the slider's js files.


    Genesis Tutorials | Follow me on Twitter

    January 13, 2017 at 6:12 am #199327
    Sridhar Katakam
    Participant

    Just came across https://tomasz-dobrzynski.com/wordpress-gonzales. Claims to provide a simple interface to control where a plugin's assets are loaded in the front end.


    Genesis Tutorials | Follow me on Twitter

    January 13, 2017 at 8:14 pm #199355
    joycegrace
    Participant

    Very interesting, thanks for the resource


    Find me at Joyce Grace (http://www.joycegrace.ca)

    February 12, 2017 at 7:50 pm #201026
    joycegrace
    Participant

    Hi again, I have a question for troubleshooting. When I try your original code on a couple sites, it works fine.

    But on a third site, I get this error: Parse error: syntax error, unexpected T_FUNCTION in /home/content/87/8254487/html/wp-content/themes/workstation-pro/functions.php on line 347

    And it references this line of your code:

    add_action( 'wp_print_styles', function() {

    Or if I take out the code for removing styles, and just leave the one for removing the script, I get the same error on this line:

    add_action( 'wp_print_scripts', function() {

    Do you know why?


    Find me at Joyce Grace (http://www.joycegrace.ca)

    February 12, 2017 at 8:47 pm #201028
    Sridhar Katakam
    Participant

    Could be due to PHP version on the server.

    Try using named functions instead of anonymous functions.


    Genesis Tutorials | Follow me on Twitter

  • Author
    Posts
Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble