You should enqueue the script in child theme’s functions.php.
for example if name of the js file is custom.js and if you place it under js folder in your child theme, then in functions.php you should add
function my_custom_scripts() {
wp_enqueue_script( 'custom-js', get_stylesheet_directory_uri() . '/js/custom.js', array( 'jquery' ),'',true );
}
add_action( 'wp_enqueue_scripts', 'my_custom_scripts' );
Here get_stylesheet_directory_uri()
will return the directory of your child theme, then array( 'jquery' )
would make your js load after jquery, if your script requires js then you should use this else you can remove or you can add the dependent script here, then the last parameter true, is to make your js load at the footer.
Related Posts:
- Loading different JS for http and https
- How should I add JavaScript to a child theme?
- How do I change number of columns in a proper way in twentyfourteen child theme?
- Trying to integrate Zoho Campaign Form [closed]
- What is the “proper” way to generate a javascript variable depending on a custom field value?
- a child theme not de-registering a patent javascript file
- Javascript asset not enqueuing with the rest
- Inherit scripts from parent to childtheme
- get_header() in backend – but keep JavaScript and CSS files
- How to load Javascript code or functions.php later in a child theme?
- Javascript File Does Not Work
- Enqueued script fails
- Is it possible to override only a part of another plugin’s / theme’s js (asset) file?
- Modifying child theme’s header
- Including js script at end of header
- adding script tag in head of specific pages
- wp_enqueue_scripts doesn’t work for template pages
- WOW.js Script Tag Initialization Header/Footer
- PHP or JS for header image rotator?
- Javascript not working on index.php but it is working on single post’s page
- What does this symbol () => mean in Javascript? [duplicate]
- What is Virtual DOM?
- How to you store data for each discord user in the discord server?
- Uncaught ReferenceError: $ is not defined?
- Get the last item in an array
- Syntax for an async arrow function
- SyntaxError: Unexpected token o in JSON at position 1
- Syntax for an async arrow function
- What is a good regular expression to match a URL? [duplicate]
- What is DOM Event delegation?
- How to quickly test some javascript code?
- getElementById returns null?
- How to compare arrays in JavaScript?
- Mouseover & Mouseout w/ Javascript
- Most efficient way to convert an HTMLCollection to an Array
- React Uncaught Error: Target container is not a DOM element [duplicate]
- document.getElementByID is not a function
- No overload matches this call. Type ‘string’ is not assignable to type ‘Signals’
- How to send an email from JavaScript
- How can I check if an element exists in the visible DOM?
- XMLHttpRequest status 0 (responseText is empty)
- What is the meaning of || in javascript?
- Coin toss with JavaScript and HTML
- Does JavaScript support array/list comprehensions like Python?
- Is there a simple way to create a javascript lookup table?
- Disable Chrome strict MIME type checking
- Why am I getting “ReferenceError: getElementById is not defined”?
- document.getElementById().value doesn’t set the value
- How to remove part of a string?
- How to run a function when the page is loaded?
- Convert normal date to unix timestamp
- jQuery replace one class with another
- Clearing my form inputs after submission
- Scope Chain in Javascript
- Changing the image source using jQuery
- Set CSS property in JavaScript?
- how to write javascript code inside php
- javascript convert int to float
- Uncaught TypeError: Cannot read property ‘toLowerCase’ of undefined
- How do I convert a JavaScript forEach loop/function to CoffeeScript
- Detecting a mobile browser
- jQuery .animate() not working
- how to add inside a text box?
- is it posible to add anime.js in WordPress
- REST API: Backbone and custom endpoint
- Gutenberg custom block plugin with custom image sizes
- Check user logged in with JS
- Can I make use of word-count.js in my own code?
- “Password Strength Unknown” Registration Issue
- Linking to Files in Root Directory Outside of WP Installation
- the Customizer – proper way to instantiate an image upload control via javascript
- Using wp_editor in TinyMCE WindowManager dialog
- Base64 & JSON Encode array in PHP, use as HTML data attribute, decode and parse in JavaScript …. with proper Escaping
- What is the correct way to import the blocks-editor?
- Include custom JS without child theme
- Change/Replace keyboard character on keypress while writing new post
- Using apiFetch for retrieving post data in Gutenberg
- Scripts not loading through function Method in WordPress Theme
- is_page_template() written in jquery/javascript
- How to load an additional script for a block in the block editor?
- wp_enqueue_scripts not enqueing correctly
- Add crossorigin to SCRIPT tag
- Sliding pages + wordpress [closed]
- JS / jQuery in Elementor pages vs JS file
- Script widget works only in admin view but not in Public
- Script only works on wordpress home page & only when Jqurery is aded using
- download svg to png size image
- Including dependencies using @wordpress/dependency-extraction-webpack-plugin
- Open href in a new window with onclick
- How to handle wordpress sso authentication with gatsby js?
- Error on clicking ‘Screen Options’ tab only at Products-related editor screen(s) and for specific user
- How are cookie values encoded?
- Hide CSS class only in single post pages
- I would like to retrive JSON value and display it in wordpress page or widget
- Where is fusion-gmap-container?
- WordPress text widget with onclick function
- Editing the source of a display for posts (to category recent)
- Dequeue set-post-thumbnail.min.js
- Why the images on mi javascript are not found?
- Browser is showing Javascript code instead of processing it [closed]