• Alessandro Ribas
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

we have two approaches to import/refer the javascript in the visualforce page:

 

approach 1:

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

 

approach 2

<script src="https://cs5.salesforce.com/resource/1331877511000/MyJavascriptFile"></script>

 

the appoach 1 is using the OOTB Visalforce component, and it is recommanded by SFDC

the approach 2 has the hard code issue when migrating the vf page from one ENV to another

 

the approach 1 put the javascript reference in the HTML head

the approach 2 put the javascript reference in the HTML body

 

Beside the above two differencies, are there any other differencies between these two approaches when import js in VF page?

 

the reason I asked this question is that I create a vf page and refer the js via approach 2.   but when I am trying to using approach 1 to fix the hard code issue, the js does not work as expected.....

 

thanks!