P
P
partyzanx2018-06-13 02:54:58
WordPress
partyzanx, 2018-06-13 02:54:58

Why is wp_enqueue_script needed if it's slow?

Here everywhere they write like connect scripts in a direct way like

<script src="/scripts/jquery-3.3.1.min.js"></script>
not right.
I connect it and other scripts in the way
wp_enqueue_script( 'jquery-3.3.1', '/scripts/jquery-3.3.1.min.js', array(), '1.0', false);

As a result, the loading of the site is 2-3 seconds longer. What for then give such advice?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Max Medar, 2018-06-13
@partyzanx

This is not advice, this is the right way. If you connect in a direct way, then such scripts / styles will not be able to take into account and, if necessary, process other plugins. Conflicts can also arise when you have a bunch of versions of jquery or another library.
When connecting via wp_enqueue_script, you can flexibly manage dependencies, prescribe the script loading/disabling logic as you like. Plugins can work with such scripts. Merge into one file, for example.
And the fact that your site takes longer to load is hosting problems or your inability to localize the problem.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question