• Resolved HelgaTheViking

    (@helgatheviking)


    I think it’d be a good idea if the scripts and styles associated with meteor slideshows only were loaded on posts/pages that required them. I’d like to use it only on the home page so it doesn’t need to load on every page. Yes I know I can conditionally dequeue the assests, but it makes sense to me to only load them when needed in the first place.

    http://wordpress.org/extend/plugins/meteor-slides/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Josh Leuze

    (@jleuze)

    That’s a great idea and I will be updating to work like this in a future release when I decide on the best way to do it.

    For now, I would go one step beyond dequeuing the scripts, and remove the script actions entirely when they aren’t needed. Check out this plugin for removing Meteor Slides scripts, that will load them on just the homepage, you could change the conditional tag if you need them elsewhere.

    Thread Starter HelgaTheViking

    (@helgatheviking)

    i know that WP shortcodes now support wp_enqueue_script (gets queued in the footer). maybe that is something you can tap into by creating a shortcode (i know you have one)

    // [bartag foo="5"]
    function bartag_func( $atts ) {
    	extract( shortcode_atts( array(
    		'foo' => '0'
    	), $atts ) );
    
           wp_enqueue_script('meteor-script');
    
           return file_get_contents(locate_template("template-file-name.php"));
    }
    add_shortcode( 'bartag', 'bartag_func' );

    with the template tag being something like:

    function bartag_slideshow($id=0){
      echo do_shortcode('[bartag  foo="'.$id.'"]');
    }

    so then you’d end up with a template tag that worked similar to how you have it now: <?php bartag_slideshow(5); ?>

    thanks for the tip on the remove actions… saves me from having to dig through the code to see how the scripts were being added.

    cheers!

    Plugin Author Josh Leuze

    (@jleuze)

    Yeah that’s exactly how I want to do it, I’m hoping to get that working with the existing template tag, but we’ll see!

    Thread Starter HelgaTheViking

    (@helgatheviking)

    cool! good luck!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Meteor Slides] Enqueue scripts and stylesheets only on pages/posts with a slideshow’ is closed to new replies.