Title: using locate_template for javascript/css
Last modified: August 20, 2016

---

# using locate_template for javascript/css

 *  Resolved [ciantic](https://wordpress.org/support/users/ciantic/)
 * (@ciantic)
 * [15 years ago](https://wordpress.org/support/topic/using-locate_template-for-javascriptcss/)
 * Hi!
 * I found myself using this:
 * `<script type="text/javascript" src="<?php echo substr(locate_template(array('
   js/3col-shelf.js')), strlen(ABSPATH));?>"></script>`
 * For overridable javascript/css files. Is there more native way to do this?
 * Thanks.

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

 *  Thread Starter [ciantic](https://wordpress.org/support/users/ciantic/)
 * (@ciantic)
 * [15 years ago](https://wordpress.org/support/topic/using-locate_template-for-javascriptcss/#post-2087818)
 * In fact the actual code I ended up using is this:
 * `<script type="text/javascript" src="<?=home_url()?>/<?=substr(locate_template(
   array('js/3col-shelf.js')), strlen(ABSPATH));?>"></script>`
 * Still looking for native way to do this!
 *  Thread Starter [ciantic](https://wordpress.org/support/users/ciantic/)
 * (@ciantic)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/using-locate_template-for-javascriptcss/#post-2088099)
 * That was before I had found out the amazing API functions: `wp_register_script,
   wp_enqueue_script, wp_localize_script`
 * If you ever consider something I did at first, then you are doing it wrong, check
   those functions first.

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

The topic ‘using locate_template for javascript/css’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 1 participant
 * Last reply from: [ciantic](https://wordpress.org/support/users/ciantic/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/using-locate_template-for-javascriptcss/#post-2088099)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
