Hi!
Thanks for your post and sorry for the trouble!
This is indeed a drawback of using “classical” theme. Due to how they are loaded, the CSS files have to be enqueued at a time when it’s not yet clear if there will be a table on the page or not. With modern block themes, this does not happen, and the CSS file will only be loaded on pages that have a table.
That said, you can use a bit of custom PHP code to filter the loading of the file, so that it can be loaded on desired pages only:
add_filter('tablepress_use_default_css', 'custom_load_tablepress_css');
add_filter('tablepress_custom_css_url', 'custom_load_tablepress_css');
function custom_load_tablepress_css( $load_css ) {
if ( ! is_page( array( 'page-slug-1', 'page-slug-2' ) ) ) {
$load_css = false;
}
return $load_css;
}
You could add this to a small custom plugin or your theme’s “functions.php” file. In that code, there’s a list of “page slugs” that can be used to define which pages the file should be loaded on.
Best wishes,
Tobias