I am using wp_enqeue_script to link to a custom.js file in my plugins folder. However I am expecting a link to show up on the page but it doesn't is there something else I am supposed to other than place this in the header.

<?php wp_enqueue_script('myscript', '/wp-content/plugins/myplugin/myscript.js'); ?>

1 Answer 1


When and where to load styles & scripts 1) & 2)

» If you are enqueueing scripts and styles, you will want to use one of these three hooks: «

  • wp_enqueue_scripts (for the frontend)
  • login_enqueue_scripts (for the login screen)
  • admin_enqueue_scripts (for the admin dashboard)

» Don’t let the names fool you — they are for both scripts and styles. We’ll probably add equivalent *_enqueue_styles hooks in 3.4 just to make it more obvious, but these hooks have all existed for some time now. A possible incompatibility with WordPress 3.3 could arise if you are using the wp_print_styles hook to enqueue styles — your styles may end up in the admin. The fix: Use wp_enqueue_scripts instead. Yes, it’s that easy. Edit: Yes, the same goes for registering styles. Registering or enqueueing (styles or scripts) should occur on *_enqueue_scripts. «

Pathes should stay relative 3)

Keep in mind that there're

  • Plugins
  • MU-Plugins
  • Drop-Ins
  • Themes
  • Themes in directories registered via register_theme_directory( $dir );


1st check if the <script> is present in your pages source code.

   ✓ → The file was hooked

   × → The hook is wrong (mostly too late)

2nd check if a file is missing with your Chrome Dev Bar or FF Firebug.

   ✓ → The file was found

   × → The path or filename is wrong (mostly typo or wrong path function)

3rd try to call the file from it's path manually to determine if you have no typo.

   ✓ → The file was found

   × → The path or filename is wrong (mostly typo or wrong path function)

Notes about sources:

1. Above is a quote Quote from WP Devel about where to add calls to wp_enqueue/register_script/style():

2. Look at the related codex page to read the same about the hooks to use

3. Another answer here on WPSE about pathes, that sums up whatcan be read in codex

  • so if I am doing it correctly, I still don't understand why I can't see the script in the outputted source. Feb 21, 2012 at 1:50
  • Look into your dev bar or firebug and check the resources if the file is missing. See Update (img).
    – kaiser
    Feb 21, 2012 at 1:52
  • the file is missing in the resource tab. I don't understand why though. And i still don't understand why this doesn't output at a <script tag> to the html how else is the browser getting the js Feb 21, 2012 at 1:55
  • Re-read the advice: Try to add the path manually and see if the file loads. If it doesn't, then you have a typo with the filename.
    – kaiser
    Feb 21, 2012 at 1:58
  • And if you can load it, then you need to update your Q with what exactly you tried plus your whole surroundings: How do you load the script, on which hook, etc. Just try to imagine, what info could would be needed to help you. Two sidenotes: Your path is simply wrong. Read the linked answer on how to set the correct path. Second: What's "connected"? Your Q-title sounds missleading.
    – kaiser
    Feb 21, 2012 at 2:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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