Title: Javascript file not executing when using WordPress child-theme?
Last modified: March 7, 2021

---

# Javascript file not executing when using WordPress child-theme?

 *  [Jono](https://wordpress.org/support/users/jono213/)
 * (@jono213)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/javascript-file-not-executing-when-using-wordpress-child-theme/)
 * I’ve linked a custom javascript file in a WordPress child theme using functions.
   php. The code doesn’t execute when the page loads, however when I run the same
   code in the console it works. The script loads which can be seen in google inspector
   under the sources tab. Does anyone know why this happens?
 *     ```
       function script_js() {
       wp_enqueue_script('tradejs', get_stylesheet_directory_uri() . '/js/custom.js', array('jquery'));
       }
       add_action('wp_enqueue_scripts','script_js', 2000);
       ```
   
 * Script doesn’t execute when page loads however works when run directly in the
   console? Ive also tried other code snippets, same results though.
 *     ```
       jQuery(document).ready(function ($) {
       $("input[type='search'").attr("placeholder", "Search CODE or Keyword");
       });
       ```
   

Viewing 1 replies (of 1 total)

 *  Moderator [t-p](https://wordpress.org/support/users/t-p/)
 * (@t-p)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/javascript-file-not-executing-when-using-wordpress-child-theme/#post-14147572)
 * I recommend asking in your theme’s dedicated support so the theme’s developers
   and support community can help you with this.

Viewing 1 replies (of 1 total)

The topic ‘Javascript file not executing when using WordPress child-theme?’ is closed
to new replies.

## Tags

 * [child theme](https://wordpress.org/support/topic-tag/child-theme/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [jquery](https://wordpress.org/support/topic-tag/jquery/)

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 1 reply
 * 2 participants
 * Last reply from: [t-p](https://wordpress.org/support/users/t-p/)
 * Last activity: [5 years, 3 months ago](https://wordpress.org/support/topic/javascript-file-not-executing-when-using-wordpress-child-theme/#post-14147572)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
