How Do I Add Defer to Script Tag in WordPress?

Adding defer to a script tag in WordPress lets you execute a script only if a certain condition is met. For example, you could use defer to load a plugin only after a user has logged in. You can add the defer tag to any script in your WordPress site, but it’s especially useful in plugin scripts.

To add the defer tag to a script in WordPress: 1. Click in the text editor area of your WordPress site. .

2. In the text editor area, type

3. At the end of the script.php file, add the defer tag. /wp-content/plugins//activate.php); } ?>.

4. Save your changes. Note that defer works best in plugin scripts, not in core WordPress files. If you need to run a script in WordPress core, use the wp_execute_script() function.

The wp_activate_plugin() function calls the plugin’s activate.php file, which in turn calls the plugin’s main() function. To add the defer tag to a script in WordPress: 1.