function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
amarendra nagireddyamarendra nagireddy 

how to use $Resource global variable....

hep me out to how to use $resource globla so many examples i seen like
{!$Resource.example_js} ,i am not getting one thing here...from where i am including this javasctipt i need to upload this file into my documents by using document tab...otherwise where can i upload this document to refer in my visualforce page. 
Hi Amarendra ,

This sysntax of code you get is to access static resource an duse in VF page .

Check belwo link how to create static resource in SFDC .               

Next how to use static resource in VF page .Below link will help you  

Basically  "{!$Resource.TestImage}"  is for single resource ,Here TestImage is the resource name .

Example two ."{!URLFOR($Resource.TestZip, 'images/Bluehills.jpg')}"  ,Here TestZip is teh zip file name and Bluehills is teh fiel name .

Let me know if it helps .


First you need to upload your CSS/JavaScript file at Setup-->Build-->Develop-->Static Resources.

To reference a stand-alone file(testCSS), use $Resource.<resource_name> as a merge field, where <resource_name> is the name you specified when you uploaded the resource. For example, if you have uploaded the css file with the name "testCSS", then you can refer it like this:
<apex:stylesheet value="{!$Resource.testCSS}"/>

You do not need to make a zip file for a single resource(testCSS).Suppose you're building a Visualforce Page where you need to use CSS(MyCss), Javascript(MyJS) and multiple images(img1, img2, etc.), then you can archive these resources into "MyVFProject" zip folder. Then upload the MyVFProject zip folder as a static resource named “MyVFProject_Resources” and refer it like this:
<apex:stylesheet value="{!URLFOR($Resource.MyVFProject_Resources, 'MyCss')}"/>

For more details: