What are the benefits of using wp_enqueue_script?

  1. Are you using a Theme that you control?

    If not, then every time the Theme updates, you’ll lose your modifications to the header. Or else, you’ll have to fork the Theme, or maintain/backport your changes every time the Theme updates.

  2. Do you only use Plugins under your control?

    If not, then you’ll have to check for script conflicts every time you activate or update a Plugin that uses a script.

  3. Are you using a core-bundled script?

    If so, then you’ll have to check for core script conflicts every time you update core, as well as every time you update a Plugin that enqueues a core-bundled script.

  4. Do you use a caching Plugin?

    If so, then you lose some or all of the benefits of script concatenation/minimizing/caching, since your script is hard-coded in the document head rather than enqueued.

Leave a Comment

tech