Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've uploaded the entire jQuery Mobile library, including the images the framework uses, as a single static resource on salesforce.

How can the JQM framework now refer to its images given their URL as static resources?

Are there good practices in this case?

share|improve this question

You need to make sure that the zip file name and the static resource name will be identical. And static res. name can contain only alphanumerics. I usually just cut the version references so later if I upgrade the library it I don't have to search & replace all occurrences. So rename the file to "jquerymobile" and upload it as resource with same name.

The official way

<apex:image id="loadingImg" 
 value="{!URLFOR($Resource.jquerymobile, '')}"/>

As you can see - URLFOR function takes extra parameter that's a subpath within the zip. Of course you probably won't be displaying images but CSS files - check <apex:stylesheet> tag.

The unofficial way

You can see what kind of file path was generated by examining the page source from the example above. In my case it's something like /resource/1354306153000/jquerymobile/ The part with strange numbers is some kind of timestamp and funny enough - you can remove it ;)

<apex:image id="loadingImg" 

(the unofficial way means you can use standard <img> tag if you want).

Regardless which one you choose - there will still be a hardcoded version number. It's your call now. I just repackage the zip with top directory renamed/completely removed so my static resources are really updating seamlessly. If you're afraid that stuff might get broken in future if you'll upload new version - leave it (and probably retain also the versioning in the zip/resource name).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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