Title: including conditional javascript
Last modified: August 20, 2016

---

# including conditional javascript

 *  [rhender](https://wordpress.org/support/users/rhender/)
 * (@rhender)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/including-conditional-javascript/)
 * hello,
 * I am trying to include a javascript only on my contact page. I added the following
   code to my functions.php file where the other javascript head links are.
 * Could anyone tell me if you see something wrong with it? I keep getting errors.“
   contact-2” is the slug on the contact page.
 * The error I’m getting says “unexpected “(” on the first line
 *     ```
       if (is_page('contact-2')) {
       		wp_enqueue_script('contact', get_bloginfo('template_url')."/scripts/contact.js");
       	}
       ```
   

Viewing 1 replies (of 1 total)

 *  Thread Starter [rhender](https://wordpress.org/support/users/rhender/)
 * (@rhender)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/including-conditional-javascript/#post-2580440)
 * The whole block of code for clearer reference…
 *     ```
       // Load jQuery
       function site_add_public_scripts()
       {
       	if (is_home()) {
       		wp_enqueue_script('qt-prototype', "http://www.apple.com/library/quicktime/2.0/scripts/prototype.js", false, '1.0', false);
       		wp_enqueue_script('qtp-poster', "http://www.apple.com/library/quicktime/2.0/scripts/qtp_poster.js", false, '1.0', false);
       		wp_enqueue_style('qtp-poster-css', 'http://www.apple.com/library/quicktime/2.0/stylesheets/qtp_poster.css');
       	} 
   
       	if (is_page('contact-2')) {
       		wp_enqueue_script('contact', get_bloginfo('template_url')."/scripts/contact.js");
       	} 
   
       	if (!is_admin()) {
       		wp_deregister_script('jquery');
       		wp_register_script('jquery', "http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js", false);
       		wp_enqueue_script('jquery');
       	}
   
       	wp_enqueue_script('jquery-cycle', get_bloginfo('template_url')."/scripts/jquery.cycle.all.min.js", array('jquery'), '1.0');
       	wp_enqueue_script('plus-one', "https://apis.google.com/js/plusone.js", array('jquery'), '1.0');
       	wp_enqueue_script('free-quote', get_bloginfo('template_url')."/scripts/free-quote.js");
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘including conditional javascript’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [rhender](https://wordpress.org/support/users/rhender/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/including-conditional-javascript/#post-2580440)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
