Thursday 15 May 2014

Difference between Static resource and Document in Salesforce



Difference between Static resource and Document

1.    A single static resource can be up to 5 MB in size, and an organization can have up to 250 MB of static resources, total.

2.    You can only create or update documents to a maximum size of 5 MB.

3.    Static resources are data cached and you can refer them easily in VF (including zip files) which store on Sales force server.

4.    Static Resources and Documents are having an absolute limit of 5MB for each document.

5.    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.

6.    You can reference a static resource by name in page markup by using the $Resource global variable instead of hard-coding document IDs.

7.    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 Static Resource

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

To reference a file in an archive, use the URLFOR function. Specify the static resource name that you provided when you uploaded the archive with the first parameter, and the path to the desired file within the archive with the second. 
 
For example:

<apex:image url="{!URLFOR($Resource.TestZip,
                  'images/Bluehills.jpg')}" width="50" height="50"/>

or

<apex:includeScript value="{!URLFOR($Resource.LibraryJS, '/base/subdir/file.js')}"/>

No comments:

Post a Comment

Activities: Assign Tasks to a Queue Salesforce Lightning

Salesforce announced to assign Tasks to a Queue beginning from Spring'20 release. How does it work? In Setup, enter Queues in th...