Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Inline flatsome.css (Flatsome Theme)
// This function can be adapted and modified to inline any theme or plugin CSS you like
// Inlining any critical CSS can make big improvements on your site speed
// Dont get carried away inlining everything - Keep it to critical and essential CSS
add_action('wp_head', 'inject_flatsome', 5);
function inject_flatsome() {
ob_start();
include 'wp-content/themes/flatsome/assets/css/flatsome.css';
$atf_css = ob_get_clean();
if ($atf_css != "" ) {
echo '<style id="inline-css" type="text/css">'. $atf_css . '</style>';
}
}
add_action('wp_enqueue_scripts', 'remove_flatsome', 101);
function remove_flatsome() {
wp_dequeue_style( 'flatsome-main' );
wp_deregister_style( 'flatsome-main' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment