How to clean up Javascript in Wordpress?

If you look at the source code of the main page where you install Wordpress plugins, there is wild terror - weight plug-in scripts and styles.

Tell me where to find the connection of all these styles and scripts? Or is there a way to take all of them into a separate file?
July 2nd 19 at 16:39
2 answers
July 2nd 19 at 16:41
There are two options for connection of scripts and styles in Wordpress.
Right: using design wp_enqueue_style('css_id') for styles and wp_enqueue_script('script_id) for scripting.

It is right not only because it says so in the codex, but also because it simplifies development. In your case for example, you can easily remove the connection of such resources, writing in functions.php the following structure:
wp_deregister_style ('css_id');
But this is only the case if the developer was good and connected resources via enqueue.

Incorrect: connect the "head" tags in the document. In this case, you need to manually find where the connection and remove/change it.
In your case this is a problem, because the developer of the plugin could plug it in one of the php files style design
echo "<script src="....."></script>"
It turns out, they have to search manually and change them.
You must understand that when a plugin update can occur problems with his work. Although, in the best case, just connect the remote from the code file.
July 2nd 19 at 16:43
1. Wild horror - a mass of plug-ins (often of dubious quality). And the scripts and styles from them - this is a consequence, a side effect.
2. Scripts and styles are connected by the theme of functions.php (see answer @ch3rri) + by plugins. Scripts/styles are connected as external files using wp_enqueue_script/style and inline through wp_add_inline_script/style. And can transmit data via wp_localize_script.
3. Disabling scripts and styles is done through wp_dequeue_script/style
4. If by "clean up" you mean delete them all, then delete the plugins themselves, otherwise it will break their functionality
5. If by "clean" you mean a concatenation of scripts and styles in one (or more) files, see caching plugins and, in fact, a concatenation of:
and such
I have a plugin but he's probably only half of the scripts combined in 1 row.. I don't know why others can't be picked up? - christina commented on July 2nd 19 at 16:46
: I have no idea - Velva.Rogahn commented on July 2nd 19 at 16:49

Find more questions by tags WordPress