+ Start a Discussion
SS KarthickSS Karthick 

External Js and Css in VFP

Hi folks,
         Can anyone tell me how to use external java script and css file in Visualforce page?

Give me some example


Thanks in advance
Karthick
Best Answer chosen by SS Karthick
Ramanarayanan PadmanabhanRamanarayanan Padmanabhan
Hi Karthick,

Download the js and css from external system.
Saev them in your static resource.
http://www.salesforce.com/us/developer/docs/pages/Content/pages_resources_reference.htm.
Please refer the above link.

Thanks,
Ram

All Answers

RamuRamu (Salesforce Developers) 
The below discussion thread should help 

http://salesforce.stackexchange.com/questions/32454/linking-to-external-css-and-js-inside-your-visualforce-page

SS KarthickSS Karthick
Hy Ramu,

     I need simple code for  linking external js to vfp

RamuRamu (Salesforce Developers) 
To link external js to VF page, you first need to load the js file to Statis resources and then use the below code in VF

<apex:includeScript value="{!$Resource.<JS File name>}"/>

Does this help ?

If you meant linking the js file hosted somewhere else, I am not sure if we can  link external js file directly to visualforce page like we do for css.

Ramanarayanan PadmanabhanRamanarayanan Padmanabhan
Hi Karthick,

Download the js and css from external system.
Saev them in your static resource.
http://www.salesforce.com/us/developer/docs/pages/Content/pages_resources_reference.htm.
Please refer the above link.

Thanks,
Ram
This was selected as the best answer
Naveen Rahul 3Naveen Rahul 3

Hi karthick,

the reasons people ask you to use the static resource

1.when u have huge traffics to your force.com  sites,your external script provider may reduce no of request come to their server.
2.So the force.com site may become slow or that particular script wont load.
3.if script wont load,u loose the functionlity.

upload the scripts to static resource folder and use them.

thanks
D Naveen Rahul.