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?
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
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:
After removing a script, please test, if the player still loads correctly on the corresponding sites.