If using WordPress and when completing a performance check on your site, you may see a recommendation to eliminate render-blocking resources. This post briefly explains and point to code that when into your WordPress site can help remove that recommendation.
How to Use
Familiarize yourself with why and how to use both wp_enqueue_style and wp_enqueue_script WordPress functions. Specifically, note the parameters used by these functions. These parameters are used as a one for one match when creating a new instance of the EV_Enqueue_Sources class. There are other parameters parameters used by this class which are shared later.
In your theme’s
A new instance of the class accepts two possible parameters. The first (
$css_args) targets CSS resources and the second (
Each parameter is an array of arrays, or a multidimensional array. For a complete list of valid key/value pairs used please see the PHPDoc of the class’s
defer attributes, the pain point can be eliminated and page performance improved upon. For more information on the benefits of these attributes used by the EV_Enqueue_Sources class , see Eliminate Render-Blocking Resources at web.dev.
Subresource Integrity (SRI)
Subresource Integrity is a security feature that can be used by sites when accessing remote resources such as CDNs. For more information please read Subresource Integrity on Mozilla’s web site. While SRI does not necessarily affect render-blocking resources, this is a nice and optional benefit to have.
preload attribute for both
<style> tags. For more information on what this attribute does please read more Preloading Content at Mozilla.
What About Other Resources?
Where to Get?
You can download the code from my GitHub Account.