I have a function in my wordpress that load a dynamic css. I checked that this admin-ajax.php call made the website slow (+5s) about.
add_action( 'wp_enqueue_scripts', 'theme_custom_style_script', 12 );
function theme_custom_style_script() {
wp_enqueue_style( 'dynamic-css', admin_url('admin-ajax.php').'?action=dynamic_css', '');
}
add_action('wp_ajax_dynamic_css', 'dynamic_css');
function dynamic_css() {
require( get_template_directory().'/css/custom.css.php' );
exit;
}
Can i save the output of this file in a folder each time i make an edit on admin , and load such a css link instead of load everytime via admin-ajax ? or call in different way to avoid this issue ? Thanks