Activity Forums Salesforce® Discussions What is Static Resource in Salesforce?

  • Nikita

    Member
    August 13, 2019 at 12:33 pm

    Static resources allow you to upload content that you can reference in a Visualforce page, including archives (such as .zip and .jar files), images, style sheets, JavaScript, and other files.

    Using a static resource is preferable to uploading a file to the Documents tab because:

    • You can package a collection of related files into a directory hierarchy and upload that hierarchy as a .zip or .jar archive.
    • You can reference a static resource in page markup by name using the $Resource global variable instead of hard-coding document IDs
    • You can use relative paths in files in static resource archives to refer to other content within the archive. For example, in your CSS file, named styles.css, you have the following style:

    You may also refer

    https://help.salesforce.com/articleView?id=pages_static_resources.htm&type=5

     

  • Deepak

    Member
    August 13, 2019 at 3:39 pm

    Force.com platform provides us a facility to upload, manage and use the content that is static (not changing) for your organization, and it can be stored under “Static Resources“. It can be a Javascript file, CSS file, an image or even a zip file containing all the files required in one zip file.

    You can refer this image in your code using expression {$Resource.Z_Test}. Below are some other examples as well:

    <!-- An image can be referenced like this -->
    <img src="<strong>{!$Resource.Z_Test}</strong>"/>

    <!-- Similarly any CSS file can be referenced like below -->
    <apex:stylesheet value="<strong>{!$Resource.sampleCss}</strong>"/>

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos