Aggressive option for CSS


Hi guys,

There is an option in beasns to compile and cache for script.

Compile and cache all the Javascript files that have been enqueued to the WordPress head. Less... JavaSript is outputted in the footer if the level is set to Aggressive and might conflict with some third party plugins which are not following WordPress standards.

We need an aggressive option for CSS too to put CSS in footer Any Solution?


Hey Usman,

While I would consider that as best practice, you may move the Beans compiled stylesheet to the footer with this code snippet:

add_action( 'wp_enqueue_scripts', 'example_dequeue_assets', 10000 );
/**
 * Dequeue assets.
 */
function example_dequeue_assets() {
 wp_dequeue_style( 'beans' );
}

add_action( 'wp_footer', 'example_enqueue_assets' );
/**
 * Enqueue assets in the footer.
 */
function example_enqueue_assets() {
  wp_enqueue_style( 'beans' );
}

Happy coding,


Thierry Muller,

Thanks a lot 🙂

Can we divide our CSS in 2 parts? Like First part will load in header and other in footer. May be we can create 2 css files, Actually I want to load cirtical css in head and other in footer

Thanks


Beans loads the UIkit components mentioned in this article by default. Unfortunately trying satisfy Google insight "blocking CSS" is very particular to individual sites and since we want to make sure Beans is a stable as possible for every user, we don't tune it that far out of the box.

That said, everything can be customized in a non detrimental way so if you want you may remove UIkit enqueues (beans_remove_action( 'beans_enqueue_uikit_components' );) and load your own version of UIkit or other CSS/LESS you may want to use.

Happy coding,

Write a reply

Login or register to write a reply, it's free!