Title: Linking to javascript files
Last modified: August 19, 2016

---

# Linking to javascript files

 *  Resolved [gary_davison](https://wordpress.org/support/users/gary_davison/)
 * (@gary_davison)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/linking-to-javascript-files/)
 * Hi,
 * I am having a few issues with my template file. I have a image viewer which requires
   javascript to function. The javascript files are in a folder within my theme 
   called js. I have linked the required javascript files to my index.php page through
   using the following code:
 * <script type=”text/javascript” src=”js/jquery-1.2.6.js”></script>
    <script type
   =”text/javascript” src=”js/startstop-slider.js”></script>
 * I have tested this as a oridnary PHP page and it functions fine. However when
   I upload it to WP it doesn’t work. Do I need my js folder to be located elsewhere
   outside of the theme? or do I need a different piece of code to include it?
 * Any help would be great.
 * Thanks

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/linking-to-javascript-files/#post-942820)
 * > <script type=”text/javascript” src=”js/jquery-1.2.6.js”></script>
   >  <script 
   > type=”text/javascript” src=”js/startstop-slider.js”></script>
 * the above should not work using a normal php page, unless that .php page is being
   loaded on your browser like so:
 * [http://www.yourdomain.com/wp-content/themes/yourtheme/yourpage.php](http://www.yourdomain.com/wp-content/themes/yourtheme/yourpage.php)
 * is that how you tested it?
 * to use that code inside a theme file, you either need to move the js/ directory
   into your blogroot, or specify the path from your wordpress’ main index.php ..
   so you would use:
 * `<script type="text/javascript" src="wp-content/themes/mythemes/js/jquery-1.2.6.
   js"></script>`
 * same for the next one, as well.
 *  Thread Starter [gary_davison](https://wordpress.org/support/users/gary_davison/)
 * (@gary_davison)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/linking-to-javascript-files/#post-942826)
 * Thanks
 * I specified the path as you stated and it works perfectly.
 * Cheers
 *  [lunantic](https://wordpress.org/support/users/lunantic/)
 * (@lunantic)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/linking-to-javascript-files/#post-942970)
 * Could somebody help a newbie? This is EXACTLY what I need to do–link the js file
   under my theme.
 * If it helps, I’m using the Inanis Glass theme. Could somebody please tell me 
   where I should put the example:
 * <script type=”text/javascript” src=”wp-content/themes/mythemes/js/jquery-1.2.6.
   js”></script>
 * (with file name changes made of course)
 * Thanks for any help you can give me.
 *  [abound](https://wordpress.org/support/users/abound/)
 * (@abound)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/linking-to-javascript-files/#post-943017)
 * I’ve created a small plugin called Add JQuery that includes jQuery … cleaner 
   than hacking the template and hard-linking to a script file.
    [ Download the zip
   file here.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Linking to javascript files’ is closed to new replies.

 * 4 replies
 * 4 participants
 * Last reply from: [abound](https://wordpress.org/support/users/abound/)
 * Last activity: [17 years, 3 months ago](https://wordpress.org/support/topic/linking-to-javascript-files/#post-943017)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
