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
Hitesh chaudhariHitesh chaudhari 

Unable to use js file as static resource in visual force page


I am trying to add static resource in visualforce page containing JS file.

But when I am trying to add it is  giving error 404 (Not Found).
 
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

The reason for getting this error is that you're not using the right syntax, or don't have the filename exactly right. 

Please refer to the below links which might help you further with the above requirement.

https://salesforce.stackexchange.com/questions/73899/visualforce-cant-access-archived-static-resource

https://salesforce.stackexchange.com/questions/11867/unable-to-access-nested-files-in-static-resource

https://stackoverflow.com/questions/5537954/salesforce-zipped-css-in-static-resource-are-not-rendered-why

https://developer.salesforce.com/forums/?id=9060G000000MVAfQAO

http://www.sfdcpoint.com/salesforce/use-static-resource-in-visualforce/

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Raj VakatiRaj Vakati
Refer this link 

https://trailhead.salesforce.com/en/content/learn/modules/visualforce_fundamentals/visualforce_static_resources



Use the $Resource global variable and the URLFOR() function to reference items within a zipped static resource.
The URLFOR() function can combine a reference to a zipped static resource and a relative path to an item within it to create a URL that can be used with Visualforce components that reference static assets. For example, URLFOR($Resource.jQueryMobile, 'images/icons-png/cloud-black.png') returns a URL to a specific graphic asset within the zipped static resource, which can be used by the <apex:image> component. You can construct similar URLs for JavaScript and stylesheet files for the <apex:includeScript> and <apex:stylesheet> components.

 
<apex:stylesheet value="{!
          URLFOR($Resource.jQueryMobile,'jquery.mobile-1.4.5/jquery.mobile-1.4.5.css')}"/>
    <apex:includeScript value="{! $Resource.jQuery }"/>
    <apex:includeScript value="{!
         URLFOR($Resource.jQueryMobile,'jquery.mobile-1.4.5/jquery.mobile-1.4.5.js')}"/>
    <div style="margin-left: auto; margin-right: auto; width: 50%">
        <!-- Display images directly referenced in a static resource -->
        <h3>Images</h3>
        <p>A hidden message:
            <apex:image alt="eye" title="eye"
                 url="{!URLFOR($Resource.jQueryMobile, 'jquery.mobile-1.4.5/images/icons-png/eye-black.png')}"/>
            <apex:image alt="heart" title="heart"
                 url="{!URLFOR($Resource.jQueryMobile, 'jquery.mobile-1.4.5/images/icons-png/heart-black.png')}"/>
            <apex:image alt="cloud" title="cloud"
                 url="{!URLFOR($Resource.jQueryMobile, 'jquery.mobile-1.4.5/images/icons-png/cloud-black.png')}"/>
        </p>