Yes. You will want to enqueue your scripts using wp_enqueue_scripts and then upload them into your child theme. I normally create a /js/
directory to keep things organized.
Here is a sample of how to enqueue a file inside of a themes JS subfolder.
function wpse_enqueue_scripts() {
wp_enqueue_script(
'js-functions',
get_stylesheet_directory_uri() . '/js/functions.js', array('jquery'), filemtime(get_stylesheet_directory() . '/js/functions.js')
);
}
add_action('wp_enqueue_scripts', 'wpse_enqueue_scripts', 999);
Related Posts:
- Custom “Uploads” Dir: “Edit Image” in Media Library broken
- Filter medias from the Media Uploader (wp.media) modal with a post meta
- Restrict file types in the uploader of a wp.media frame
- Uppload image from another source wp.media
- Multiple media uploader buttons target only one input on the same page
- Show a popup message when file is uploaded
- wp_handle_upload returns a critical error response or invalid form submission
- How to get file object from file_attachment?
- How to locate the js code and php code for certain function?
- uploading image to wordpress site with javascript fetch function failed
- Dynamically creating charts of each row in an HTML table with chart.js
- Failed to load resource: the server responded with a status of 500 (Internal Server Error) in Bind function
- Scroll to an element with jQuery
- Cannot open local file – Chrome: Not allowed to load local resource
- How do you reverse a string in-place in JavaScript?
- How to set NODE_ENV to production/development in OS X
- Uncaught TypeError: Cannot read property ‘length’ of undefined
- Python to JavaScript converter
- Set style using pure JavaScript
- Check if element exists in jQuery
- Checking a Url in Jquery/Javascript
- Usage of the backtick character (`) in JavaScript
- Fastest way to duplicate an array in JavaScript – slice vs. ‘for’ loop
- What is the difference between call and apply?
- AJAX response error: net::ERR_EMPTY_RESPONSE
- TypeError: Cannot Set property ‘onclick’ of null
- Sorting strings in descending order in Javascript (Most efficiently)?
- How would I call a javascript function in html?
- Mismatched anonymous define() module
- Function is not defined – Uncaught ReferenceError
- Convert UTC date time to local date time
- How can I convert a string to boolean in JavaScript?
- “.addEventListener is not a function” why does this error occur?
- How do I include a JavaScript file in another JavaScript file?
- Textarea Auto height
- Angular 2 – Using ‘this’ inside setTimeout
- Download data URL file
- Why use Redux over Facebook Flux?
- Discord error cannot read property ‘isFocused’
- onClick not working React js
- What language is JavaScript written in?
- How to output numbers with leading zeros in JavaScript?
- Remove not alphanumeric characters from string
- Scroll to bottom of div?
- How to sort in mongoose?
- “Uncaught TypeError: a.indexOf is not a function” error when opening new foundation project
- How do you serve a file for download with AngularJS or Javascript?
- How can I cache image files locally with PhoneGap / Cordova?
- how to display a div triggered by onclick event
- Detect a finger swipe through JavaScript on the iPhone and Android
- JAX post error : Refused to set unsafe header “Connection”
- How to use onBlur event on Angular2?
- img onclick call to JavaScript function
- Bootstrap Collapse not Collapsing
- How to scroll to top of page with JavaScript/jQuery?
- Check if a JavaScript string is a URL
- Submit form without reloading page [duplicate]
- “React.Children.only expected to receive a single React element child” error when putting
and in a - What is the difference between Bower and npm?
- How to embed an autoplaying YouTube video in an iframe?
- Cannot read property ‘style’ of undefined — Uncaught Type Error
- clearInterval() not working [duplicate]
- How to use Head JS with all enqueued scripts?
- How to add code to just before closing body tag
- Switch to the library tab in the media uploader
- Customizer JS API: Defining control settings
- How to resize image on client-side before upload?
- Customizer JS API: Adding Setting Dynamically Not Working
- Updata Metadata WP Rest API
- How to check if customize previewer is refreshing?
- Customizer JS API: Adding a “dropdown-pages” control
- Morris.js for WordPress?
- Where is the WP auto-save draft JavaScript?
- wp.editor.initialize does nothing
- Enqueue js script to footer
- Add A Tag To A Post Through JavaScript In Gutenberg UI?
- Setting/unsetting terms using the Backbone JavaScript client
- Load page in customizer preview on panel click?
- Why WordPress not using JSON_UNESCAPED_UNICODE by default?
- Add script to page at certain location in wordpress
- get_header() in backend – but keep JavaScript and CSS files
- Absolutely print script in footer
- How can I put this JavaScript into WordPress? [closed]
- Some problems in custom widget
- How do you create your own link preview for my website?
- Can’t get rid of JQMIGRATE: Migrate is installed, version 3.3.2. Manually updated all the libralies and site. 5.8.2
- Need help in fixing javascript in WordPress
- Uncaught TypeError: r is not a function
- How to show cities according to the state in Form using Javascript? [closed]
- Redirect to homepage if attmpting to leave intranet [closed]
- Twenty seventeen theme dropdown menu issue
- How to correctly load this jquery script through the file functions.php?
- Unserialize WP_Options options programatically?
- javascript errors on mobile browser, not on desktop
- Loading 2 Different Version of JS files [closed]
- Adding react app to an existing wordpress website
- Javascript file not included only on home page
- Get current day using javascript [closed]
- Passing object to FormTokenField suggestions
- How to Update a variable even if the web page reloads in js