Try loading your script in the footer:
wp_enqueue_script( 'test', get_template_directory_uri() . '/js/testJS.js', array('jquery'), false, true );`
The true
parameter on the end tells WordPress to load this script in the footer instead of the header.
For more information, visit the Codex: https://developer.wordpress.org/reference/functions/wp_enqueue_script/
Related Posts:
- pass object/JSON to wp_localize_script
- How to alter the text of the post “Excerpt” box label in WordPress post editor?
- What is the best practice for customizing a plugin’s JavaScript/jQuery?
- How do I “unhook” / de-register jQuery so that it’s not called as part of wp_footer();?
- How to Change CSS Variable value in Theme Customizer Live Preview
- WordPress Google Maps in Custom Theme
- wp_enqueue_script being ignored in custom theme
- Getting jquery to work with custom theme
- Adding wp_enqueue_media(); causes problem
- How to correctly add JQuery in a WP theme?
- Toggle Sidebar Display
- Including Javascript options
- Unhook jQuery from WooCommerce via `functions.php`? [closed]
- Fancy-box Esay wordpress plugin fails to work on Multilingual site
- WP 3.1 upgrade breaks AutoFocus+ theme
- Difficulty loading jQuery with wp_enqueue_script
- jQuery not available to other scripts
- Implementing FancyBox
- How to: JQuery multiple wordpress media uploader buttons in the same options page?
- Post thumbnail to append post content via ajax click event
- Would to use AJAX to get an option from the database and use it in a jquery setup or is there an alternative to consider?
- Using page-id-{ID} from body_class() in local dev, versus live staging
- My jQuery is enqueued properly. So why isn’t it working?
- Custom theme, contact form 7 & fast secure form doesn’t work
- Javascipt issue on custom theme
- How to make javascript work on theme options page
- JQuery undefined and Stylesheet loads in bottom along with js files
- Weirdness in jQuery supplied with WordPress
- jQuery from parent theme loaded with many other scripts in a single min.js file
- Trouble in enquing all js files under certain directory
- How do I implement jPanelMenu?
- loading javascript after jquery is loaded
- MapPress Easy Google Map in Jquery Tabs Problem
- I don’t think WordPress is loading jquery or bootstrap js
- how can i remove js file from my footer in wordpress
- How to properly use AWS SES for a contact form?
- Embedding CodePen Calorie Script – jquery error
- How to load jQuery with Ajax in WP version 5.3.2?
- How to enqueue scripts properly with ES6 webpack?
- Infinite scroll without plugin using ajax
- change background image on scroll
- how to add jquery to wordpress
- jQuery conflict in WordPress, works fine in HTML
- How would I get this to work – send to post from thick box
- FitVid not working for iframes on particular theme install
- Enable WP to accept standard jQuery code embeding between the tags [duplicate]
- WordPress custom jquery not found
- Passing a location-dependent array via wp_localize_script within a shortcode
- enqueue script if page is not equal to
- Set start page depending on screen width [closed]
- WordPress Subpages Fancybox Trouble
- Theme now uses require.js and enqueue script no longer works
- can’t add EVENT LISTENER to a element
- jQuery Snippet Not Working on WordPress Site [closed]
- WP Customizer get control value on change
- Execute javscript when theme customizer loads (autosave issue)
- WordPress Includes mejs 404 error
- How to add custom css file in theme?
- CSS not updating in browser when I change it
- Get url of thumbnail from the media uploader
- How to: Update live sites theme from version control repo via plugin or library? [closed]
- Adding items to page template dropdown on Page Edit Screen
- How to use logout function on custom menu link?
- How to add a text widget during theme activation
- WordPress Theme customisation CSS
- Why does this loop only work on the homepage?
- Nesting Functions within Functions
- How to determine if post has widget content?
- Custom Script Section Only Echoes Text
- Set multiple templates per post
- Place the page title into the short code
- What is the best way to organize template parts?
- wp_enqueue_script outside functions.php file?
- How to implement a $_SESSION alternative in WordPress inside a theme without a plugin?
- How can I make my options in an array and store theme in WP options one DB row?
- Differences between developing custom themes for wordpress.com and wordpress.org?
- Easy to develop on a URL that is changed for production?
- How to detect and display a page only for IE?
- Getting author URL outside the loop
- Change image size depending on page
- How to include a mu-plugin as a theme dependency?
- How to use ajax in wordpress and sending the data without refreshing ?
- Adding an external link to product grid list pages for woocommerce
- What and where are the WordPress core-bundled scripts?
- How do I get from search_theme_directories() to the $stylesheet (name) for switch_theme()
- Tabbed theme options query about add_settings_section callback function
- How to know if I am on 1st page
- I don’t know why categories are showing below post
- WordPress Custom font not found
- How do I control the header space in non-front pages in Twenty Seventeen?
- Target second from last post in loop
- Customizer API way function is_customize_preview() works only in main page?
- Advantages/Disadvantages Using Theme Editor Instead of Pages
- Magnific Popup – Add Caption to Images
- Why do WordPress developers use so many opening and closing PHP tags when developing themes? [duplicate]
- editor style css and page template with and without sidebar
- 3 x 3 grid of posts on the home page
- The normal loop with different styles doesn’t work in search.php
- Pass custom css class to add_menu_page
- How to force unlink on attached/inserted images?