I've uploaded a jQuery library document into our SF Shared Documents and want to be able to reference that document in a sidebar HTML component. I've tried many variations of the below with no luck:

<script type="text/javascript" src="/servlet/servlet.FileDownload?file=015f0000000AdXO"></script>

Can someone give me an idea of how the path should be specified?

Thanks in advance.

  • If it is the main jQuery JavaScript, an alternate approach is to just reference it from a CDN location like this <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>.
    – Keith C
    Apr 15, 2014 at 19:56
  • Yeah @Keith, I was trying to avoid an external call for each page that loads.
    – Adam H.
    Apr 15, 2014 at 20:06
  • 1
    Well its the client (the browser) making the request so its a remote call whether to the CDN location or to a Salesforce location... And as long as all your pages reference the same CDN location your browser will cache.
    – Keith C
    Apr 15, 2014 at 20:11
  • 1
    static resources can be used/referenced without the timestamp @Keith C, it's optional
    – greenstork
    Apr 15, 2014 at 22:21
  • 1
    @greenstork From wiki.developerforce.com/page/… looks like up to 24 hours later you might and then only after user's clear their browser's cache.
    – Keith C
    Apr 15, 2014 at 22:26

1 Answer 1


The best practice is to upload JavaScript libraries as Static Resources (Develop -> Static Resources). Then, use an <apex:includeScript> for example:

 <apex:includeScript value="{!$Resource.yourJavaScriptLibrary}"/>

Also, you can upload zip files as Static Resources:

 <apex:includeScript value="{!$Resource.SiteFiles,'SiteFiles/JavaScript/Version1.js'}"/>

Note: make sure the Static Resource's Cache Control is set to Public

Image of a Static Resource.  Make sure to set Cache Control to Public!

  • 2
    The question related to a sidebar component where no "{!}" processing is available. What do you propose for that situation?
    – Keith C
    Apr 15, 2014 at 22:45
  • if your problem was solved as your comments suggest, mark it as solved. ;) or maybe write it up as a solution . . . Apr 15, 2014 at 23:05
  • The wink on the above comment is inappropriate. Clearly this answer is insufficient, considering the original question. At the time of writing this comment, I see no answer submitted for this question that can be considered as having solved the question. Apr 16, 2014 at 1:09
  • @amatorVitae, I don't see how to mark a comment as solved. I didn't really want my comment to be an answer, as I didn't feel that it was really a solution to the question, only a revelation of my blunder. Should I delete the post? Or should I mark it as the answer?
    – Adam H.
    Apr 16, 2014 at 12:29
  • you write up a solution. it's easy. the idea is if someone has a similar issue a year from now, they will be able to easily see how to solve their issue. I ask you to write up a solution for the common good Apr 16, 2014 at 19:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .