Assuming your resource is included in your Plugin:
plugins_url()
is the URL to\wp-content\plugins\
(Codex ref)
So if you have a .js file in \wp-content\plugins\plugin-slug\file.js
:
<?php echo plugins_url() . '\plugin-slug\file.js'; ?>
BUT WAIT!!
If your purpose is actually to load a javascript file, you actually want to enqueue that file, using wp_enqueue_script()
, hooked into the wp_enqueue_scripts
hook.
And wp_enqueue_script()
uses the filepath rather than the URL, so you could use dirname(___FILE___)
if that’ what you’re comfortable with.