How prevent loading player JavaScript at each wordpress page?

On every page in my blog (Wordpress) the podlove player js is attracted. Which is quite big (and rightly criticised by google as unnecessary)
How can I prevent this?

<script type='text/javascript' src='https://cdn.podlove.org/web-player/5.x/embed.js?ver=5.3.1' id='podlove-web-player-player-js'></script>

it is enough if the player would be attracted on all post pages and episodes
but not on every page (especially not on the homepage)
Can anyone help me?
Thank you very much

Hey,
right now this is not possible. I couldn’t apply a quick fix so I tracked the issue here: https://github.com/podlove/podlove-web-player-wp-plugin/issues/66

1 Like

Sorry for digging into old topics.

I’ve resolved this with this code for Player v4. It checks, if the site is a single post site and checks for the post type.
Additionally, it removes a font that’s only needed in the admin area from the frontend.

If you embed your player on the main site (instead of only on single post sites) or use v5, then you need to edit the code a bit.

function nt_dequeue_podlove() {    
if (!is_single() || get_post_type() !== 'podcast') {
        wp_dequeue_script("podlove_frontend");
        wp_dequeue_script("podlove-player4-embed");
        wp_dequeue_script("podlove-pwp4-player");
        wp_dequeue_style("podlove-frontend-css");
      }

      if (!is_admin()) {
        wp_dequeue_style("podlove-admin-font");
      }
    }

    add_action('wp_enqueue_scripts', 'nt_dequeue_podlove');

Put it into your themes functions.php and fiddle around with the script-slugs like podlove-web-player-player, if using Player v5 (have a look into your source code, find the podlove-scripts and remove the trailing -js to get to the slugs).
For example:
image

After removing a script, please test, if the player still loads correctly on the corresponding sites.

1 Like