Title: How do I load Javascript on specific pages only?
Last modified: April 16, 2021

---

# How do I load Javascript on specific pages only?

 *  [appelby1010](https://wordpress.org/support/users/thegreatdanton/)
 * (@thegreatdanton)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/how-do-i-load-javascript-on-specific-pages-only/)
 * Hi there,
 * I have javascript loading on my site before the </body>. The issue is that this
   is loading across all pages. How do I load this on specific pages only?
 * Thanks
    A

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

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [5 years, 1 month ago](https://wordpress.org/support/topic/how-do-i-load-javascript-on-specific-pages-only/#post-14328410)
 * How are you enqueuing the javascript?
 *  [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * (@rossmitchell)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/how-do-i-load-javascript-on-specific-pages-only/#post-14330307)
 * An expedient way to do this would be in a page template.
    You need to be using
   a child theme. Copy a basic page template from the parent theme into your child
   theme directory. Do your customisations there. Nominate this as the template 
   to be used on your special pages. I am sure that there are more elegant ways 
   to do this, but this will get you there.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/how-do-i-load-javascript-on-specific-pages-only/#post-14331283)
 * Assuming you enqueue from the “wp_enqueue_scripts” action, you might be able 
   to conditionally check against `get_queried_object_id()` returned value. This
   works well for single posts and pages. It also returns term object IDs for term
   archive requests, so there could be some ambiguity in some cases. If that’s a
   problem, get the entire queried object instead and check with `is_a()` as well.
   There will not be any value for the blog posts listing like the default home 
   page.

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

The topic ‘How do I load Javascript on specific pages only?’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 4 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [5 years, 1 month ago](https://wordpress.org/support/topic/how-do-i-load-javascript-on-specific-pages-only/#post-14331283)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
