---
schema_version: "1"
id: 1ebb53e1d1f838b111d334aa92189edca08125d246582599e87e6e59a465804e
title: Using JavaScript in Visualforce Pages
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-pages-developers-guide/guides/pages/javascript/pages-javascript-intro.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/guide/pages-javascript-intro.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 6a80e53ef9d86c137622c53a63af0e1aa7ec1c84318614f5e8b948c9ca750118
products:
  - Visualforce Developer Guide
  - Platform Developer Content
---

# Using JavaScript in Visualforce Pages

Using JavaScript in Visualforce pages gives you access to a wide range of existing JavaScript functionality, such as JavaScript libraries, and other ways to customize the functionality of your pages. Action tags, such as `<apex:actionFunction>` and `<apex:actionSupport>`, support Ajax requests.

**note:** By including JavaScript in a page, you are introducing the possibility of cross-browser and maintenance issues that you do not have when using Visualforce. Before writing any JavaScript, you should be sure that there is not an existing Visualforce component that can solve your problem.

The best method for including JavaScript in a Visualforce page is placing the JavaScript in a static resource, then calling it from there. For example,

```visualforce
<apex:includeScript value="{!$Resource.MyJavascriptFile}"/>
```

You can then use the functions defined within that JavaScript file within your page using `<script>` tags.

**tip:** When using JavaScript within an expression, you need to escape quotes using a backslash (\\). For example,

```visualforce
onclick="{!IF(false, 'javascript_call(\"js_string_parameter\")', 'else case')}"
```

