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?

1 Answer 1


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, 'jquery.mobile-1.2.0/images/ajax-loader.gif')}"/>

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/jquery.mobile-1.2.0/images/ajax-loader.gif. 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).

You must log in to answer this question.

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