Benefits to enqueuing site scripts/stylesheets?

Why are you manually controlling Plugin’s javascript files?

1) It’s never bad practice to do things like they are supposed to be. That way, when you need to, it’s not a mountain to climb.

2) If you’re sick and I’m hired to look at your code, I expect javascripts and css to be loaded the proper way. Pasting them in the will only cost me more time and confusion.
3) If you ever plan to use a plugin (or your client installs a plugin) or such which loads the same javascript as your theme does, you’re in for a conflict.
4) wp_enqueue_script gives you control over dependencies and can put the javascript code in your order in the header or at the bottom of the page. More control = always better! (even if you don’t use it, you have the option to expand).
5) You can use version numbering.
6) You can load scripts only on the pages that need that code.

You’re basically just giving yourself more work…..

I think the question should always be “is it justified not to use it?” instead of “is it justified to use it?”.

EDIT FOR UPDATED QUESTION:

I think you kind of answered your own question here. When you don’t use ANY advantage that wp_enqueue_script() gives you, it will not give any advantage. (The logic :P).

I would still load it through wp_enqueue_script() if I were you though. You said you only have 1 .css file & 2 .js files. If I understand you correctly, you manually manage and compile all your javascript & css to these few files. New javascript & css will always still be compiled to those files. In that case you can just as easily type the needed wp_enqueue_script() once and you will never have to look at it again.

It won’t give many (important) advantages, but still:

1) You will then be more according to standards, which will still be less confusing.

2) If you ever want to, you can instruct wordpress to drop the specified .css or .js file on a specific page or something similair. (I once made a website where i had no need for any javascript on that particular page, so the scenarios exists).
3) May you ever in the future, for whatever reason need to compile seperate .js files (maybe because you have a very js-heavy page on your website), you can choose on a page basis how and which one you will load.

Like I said before, I think you should look for reasons not to do it according to standards. Not the other way around. So instead of me trying to give answers why you should. Why don’t you give reasons why you shouldn’t?

The only disadvantage I see is that it’s (maybe) easier to just put in the footer instead of having to put it in functions.php.

But if that’s the only disadvantage, like I said, you can just do it once and never have to look at it again. So that’s not a real disadvantage IMHO.

Leave a Comment

tech