If there are several plugins on your WordPress sites there may be more than one copy of jQuery, or other script, that’s loaded, especially if you’re relying on the same scripts for control of the site theme as well. Only one copy of each script should be loading up. More than that represents wasted bandwidth for you and wasted time for your site visitors.
To control what scripts are used on your site it may be wise to learn how to disable scripts from loading in the first place. Similar methods can be applied to streamline the number of scripts or stylesheets loaded onto your site.
Check out this great tutorial on disabling scripts and styles. Thanks for sharing, Justin!
You’ll need to modify the
functions.php file of your theme to remove styles or scripts. The technique is similar in each case.
- Find the ‘handle’ of the script that you’d like to remove.
- Pass the script handle to
- Wrap one or more ‘deregistrations’ in a new function, like
wp_print_scriptsmethod and add your new function to the
functions.phpfile of your theme.
From the reference on
add_action in the WordPress codex we can see that two arguments are required, namely the
$tag or handle of the script and the
$function_to_add or the function to which the script is hooked. Two optional parameters can be added to the
add_action function to specify the
$priority or the order in which the functions are executed, and
$accepted_args or the number of arguments that the function accepts. Generically,
add_action( $tag, $function_to_add, $priority, $accepted_args );
In the example above we’ve used ‘wp_print_scripts’ for
$function_to_add while the optional