Friday, June 1, 2012

Static Resource vs Document


Static Resources v/s Documents:

  1. Static resources are data cached and you can refer them easily in VF (including zip files) which store on Sales force server.
  2. Static Resources and Documents are having an absolute limit of 5MB for each document.
  3. You can package a collection of related files into a directory hierarchy and upload that hierarchy as a .zip or .jar archive), images, style sheets, JavaScript, and other files.
  4. You can reference a static resource by name in page markup by using the $Resource global variable instead of hard-coding document IDs.
  5. JavaScript or CSS is preferable to including the markup inline. Managing this kind of content using static resources allows you to have a consistent look and feel for all your pages and shared set of JavaScript functionality.

Referencing a Static Resource in Visualforce Page:

<apex:image url="{!$Resource.TestImage}" width="50" height="50" />
or
<apex:includeScript value="{!$Resource.MyJavascriptFile}"/>

No comments:

Post a Comment