To increase the loading speed, I would like to only enable Event Manager plugin on the pages where it's actually used. For that, I wrote this piece of code:
// deregister unnecessary plugin scripts:
function my_deregister() {
if ( !is_page('events') ) {
wp_deregister_script( 'events-manager' );
}
}
add_action( 'wp_print_scripts', 'my_deregister', 100 );
However, the problem is that this event plugin creates a single page for each event and it needs to be enabled on those sub-pages, too. Apparently, each generated page is named differently. For instance, www.mysite.com/events/EventNameEventDate.
So I would like to have the plugin disabled on all pages except for 'events' and its sub-pages (of which I will obviously not always know the count and names). The is_page() works fine for the Events page but how do I modify it so that it recognises its sub-pages and enables the plugin scripts on them, too?
This was just a plugin specific example for easier understanding of the problem, but the question is generic and plugin independent.