WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to include an optional template part in the theme which requires some jQuery plugin. Is it ok to include the wp_enqueue_script in that specific file? Or it should always be included in the functions.php file?

Also, is it ok to write some javascript code in that specific file? The script works, but my question is about WordPress coding standard.

share|improve this question
possible duplicate of How to Link External jQuery/Javascript files with WordPress – Chris_O Nov 16 '12 at 11:11

I prefer to enqueue it to the get_template_part_{$slug} action to keep all the scripts in one place & more organized. But you can do it either way you like

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.