It’s normally recommended to always use a full URL, not a partial location like above. it just takes the possible guess work out of file locations, both for browsers nd us developers that have to come and look at it later on. 🙂
As for the path, it doesn’t matter where you put it as long as you can access it. If it was me, I’d have a folder on the main root of the site and sit it in there.
/root/
/javascript/
/jquery.js
/wp-content/
index.php
Then have the script location set like this:
$location = home_url( '/javascript/jquery.js' );
Doesn’t WordPress load jQuery by default?
I don’t think you need to load it again from some other source because WP already bundles that in.
@shariqkhan2012
Doh! You are right. I tried the page with the removed link and it worked fine.
But I have another one that like to store locally:
<script src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
what’s the best place to put it, and how can I link it? I am not sure what the root is.
what’s the best place to put it
It depends on whether the script in question is a part of a plugin or a theme.
If you need the script for a plugin that you are writing, then store them inside a sub-directory within your plugin (or theme)
However, if the script in question has no link to your plugin (or theme), then you shouldn’t bother with it.
May I ask whats your use case?