Reputation: 2704
In mulitple views I am including an external javascript library with this HTML:
<script type="text/javascript"
src="http://static.jstree.com/v.1.0pre/jquery.jstree.js">
</script>
In reading through the Rails 3.1 Asset Pipeline documentation and discussions I get the impression that vendor/assets/javascripts
is a place were that file should be referenced. I'm guessing that I could download a copy of the file (jstree.js
) and place it in that directory. However I'd like to have it loaded off the project site instead of making a local copy of it.
What do I put in vendor/assets/javascripts to pull a copy of jstree.js off the remote server? Do I create a .js file with some sort of remote load code? There seems to be all sorts of approaches and/or confusion on how to best do this ( see the long list of answers to this question: How do I include a JavaScript file in another JavaScript file? .)
Is there a "Rails Standard" convention/library/process for doing this? I'm a javascript neophyte, so please be explicit, thanks.
Upvotes: 9
Views: 5906
Reputation: 230336
No, there's no way you can put a "reference" to a remote file in the assets folder. You either download a copy and put into assets, or reference remote file with <script>
tag.
Having a copy is not a bad idea, really. At least, you know that it works and the file hasn't changed (unless you changed it yourself). When you load a remote file, all sorts of surprises can happen :)
Upvotes: 10