

As this is only for inspecting purposes and to see which scripts are hooked, this code snippet should be removed before going live. You can add that to your theme’s functions.php file or into a plugin if you want. Do not use it in production because it will stop your site. To inspect this action, we can use this code snippet just for developing and inspecting purposes. Since this global variable holds many other actions and filters, we will only need the functions registered for action wp_enqueue_scripts. Inspecting Action wp_enqueue_scriptsĪll actions and functions that are hooked into those actions are saved into a global variable $wp_filters. That is great, but when we do not need that script, it only hurts our performance. You can do that just by using simple code snippets like this one:Ĭan you see what is consistent with both theme and plugin enqueueing? We are using the same action hook wp_enqueue_scripts.īy enqueueing scripts into footer we can improve the WordPress performance by a little. This enables us, other developers, to control the loading of the scripts and styles and even disable their loading on pages where we do not need them. When coding your own plugin or theme, you should always enqueue your scripts and styles and not hard code them into your templates. We should be able to remove those scripts or styles since those HTTP requests can be saved and rendering of our entire home page improved. In our example, we do not use any of WooCommerce widgets or the page builder on our home page. For example, let’s assume that we use WooCommerce or SiteOrigin’s Page Builder.

Many plugins load their own styles and scripts which can lead to a bloated WordPress site with assets that are not needed on a page.
Wordpress enqueue script on specific admin page how to#
We will also see how to block loading of scripts from certain plugins. Ever wondered how to control script and style loading to achieve better WordPress performance? In this tutorial we will learn how WordPress loads the scripts and how can we control which script or style will be loaded.
