events-calendar-pro/src/resources/css/widget-calendar-full.css does not get picked up by Autoptimize.
Expected result: Autoptimize fetches properly hooked stylesheets and javascript files; concatenates and minifies them.
However the above CSS is not picked up by Autoptimize, instead it is printed inline in the HTML – not in or in the footer for that matter.
The css is registered using the Widget Class as of now, which might be too late for Autoptimize and other hooks. A possible fix is to simply register the script using a more convenient (and better placed) action, like so:
add_action(‘wp_enqueue_scripts’, ‘example_register_scripts’);
function example_register_scripts {
wp_register_style(‘events-calendar-pro’, ‘css/file.css’, false, ‘1.0.0’);
}
(registered scripts are not printed until an action enqueues them)
and then within whatever shortcode and/or Visual Composer component that requires the CSS you can use:
wp_enqueue_style(‘events-calendar-pro’);
this adds to benefits:
First the CSS will not be placed within some strange place in the middle of the HTML within the first component. It might get placed in the footer (minor drawback compared to current behaviour).
And the larger benefit that it will actually be picked up by autoptimize, concatenated and minified along with other files.