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
Fatty88Fatty88 

Salesforce Static Resource Javascipt And CSS

i have a requirement where i need to create a SF installable and i am trying to keep as few Static Resources as possible. In fact, i am trying to have just one BIG static resource. But i am facing a problem. I have successfully put all the css files in one large file and i have accessed the the files within it in the following way:

<apex:Stylesheet value="{!URLFOR($Resource.JqueryResources, 'First.css')}"/>
<apex:Stylesheet value="{!URLFOR($Resource.JqueryResources, 'Second.css')}"/>
<apex:Stylesheet value="{!URLFOR($Resource.JqueryResources, 'Third.css')}"/>
<apex:Stylesheet value="{!URLFOR($Resource.JqueryResources, 'Fourth.css')}"/>
If in the same file (i.e. JqueryResources) if i keep few javascript files, i am unable to access these files as:

<apex:includeScript value="{!URLFOR($Resource.JqueryResources, 'Javascript.js')}"/>
I currently making it work like this

<apex:includeScript value="{!$Resource.JavascriptResource}"/>
where JavascriptResource is name of the stand alone static resource containing Javascript.js. So how do i fix this??
bob_buzzardbob_buzzard
If you are zipping the file then there should be no difference between the ability to access css and javascript files - I've used this technique dozens of times.  
Fatty88Fatty88
Nah, i think i compressed using WinRar. But its able to access CSS in rar file but not .js in the rar file. 


MIME Type for the compressed file is application/octet-stream
bob_buzzardbob_buzzard
The docs only mention .zip and .jar files, so it may be that RAR isn't fully supported.  I'd turn it into a zip, as I know that works fine.
Fatty88Fatty88
I tried doing what you said .... still it didnt work   

    <apex:Stylesheet value="{!URLFOR($Resource.JqueryResource, 'demo_page.css')}"/>
    <apex:Stylesheet value="{!URLFOR($Resource.JqueryResource, 'demo_table.css')}"/>
    <apex:Stylesheet value="{!URLFOR($Resource.JqueryResource, 'jquery-ui-1.10.3.custom.css')}"/>
    <apex:Stylesheet value="{!URLFOR($Resource.JqueryResource, 'ColVis.css')}"/>
    <apex:Stylesheet value="{!URLFOR($Resource.JqueryResource, 'TableTools.css')}"/>
    <apex:Stylesheet value="{!URLFOR($Resource.JqueryResource, 'TableTools_JUI.css')}"/>
                          
    <apex:includeScript value="{!URLFOR($Resource.JqueryResource, 'FixedHeader.js')}"/>
    <apex:includeScript value="{!URLFOR($Resource.JqueryResource, 'JQuery.js')}"/>
    <apex:includeScript value="{!URLFOR($Resource.JqueryResource, 'JqueryDatatable.js')}"/>
    <apex:includeScript value="{!URLFOR($Resource.JqueryResource, 'ColVis.js')}"/>
    <apex:includeScript value="{!URLFOR($Resource.JqueryResource, 'TableTools.js')}"/>
    <apex:includeScript value="{!URLFOR($Resource.JqueryResource, 'ZeroClipboard.js')}"/>


where JqueryResource is the ZIP file that has all  the files
bob_buzzardbob_buzzard
And all of the JavaScript/CSS is at the top level of the zip file (i.e. there are no folders etc)?  
Fatty88Fatty88
They are all at the top level,  yes
Fatty88Fatty88
Is my syntax wrong anywhere?

bob_buzzardbob_buzzard
Not that I can see.  What do the includes look like when the page is rendered (i.e. if you view source)?