• Resolved OkorieWare

    (@okorieware)


    It would be more efficient on bandwidth, if we had an option to select which page(s) we want the plugin to be active.

    Also, it is good practice to load scripts in the footer instead of the header: wp_enqueue_script(“scap.soundmanager2-js”, “…/soundmanager2-nodebug-jsmin.js”, [], null, true);

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor mbrsolution

    (@mbrsolution)

    Hi, you can use the following code to only play in the home page.

    <?php 
    if(is_front_page()){
        echo do_shortcode('[sc_embed_player fileurl="URL OF THE MP3 FILE" autoplay="true"]'); 
    }
    ?>

    You can also use page Id as per the following documentation.

    https://developer.wordpress.org/reference/functions/is_page/

    Also, it is good practice to load scripts in the footer instead of the header: wp_enqueue_script(“scap.soundmanager2-js”, “…/soundmanager2-nodebug-jsmin.js”, [], null, true);

    In regards to the above, I have submitted a message to the developers to investigate further your request.

    Thank you

    Thread Starter OkorieWare

    (@okorieware)

    I already understand how to use the shortcode.

    The problem is that Compact WP Audio Player load its styles and scripts on every single page, whether or not it is being used.

    To maintain performance, I currently have to add the following…

    $page = $_SERVER["REQUEST_URI"];
    if ($page !== "/media/")
    	add_action("init", function () {
    		remove_action('init', 'wp_sc_audio_init');
    		remove_action('wp_footer', 'scap_footer_code');
    	});

    A good example of what I mean would be in the Header Footer Code Manager plugin, that has a Site Display: Specific Pages option.

    Plugin Contributor mbrsolution

    (@mbrsolution)

    Hi, I have submitted a message to the developers to investigate further your request.

    Kind regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Optimization: Only load on specific pages’ is closed to new replies.