It seems to me best to separate styles, from scripts and other assets. This worked:
function my_theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_parent_theme_file_uri() . 'style.css' );
}
add_action( 'my_theme_enqueue_styles', 'wp_enqueue_styles' );
function my_theme_enqueue_assets() {
wp_enqueue_script( 'behavior', get_theme_file_uri( 'behavior.js' ), array(), null, true );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_assets' );
Related Posts:
- How to load scripts/styles specific for a page
- Advanced method to control cache of enqueued style/script
- How do I dequeue a Stylesheet, stored in an ‘Assets’ folder?
- custom post with loading script per single post
- TinyMCE custom stylesheets for different post types
- How to combine multiple CSS files and concatenate JavaScripts if WordPress recommends enqueuing them?
- Dequeue Scripts and Style for Mobile not working?
- Enqueuing External Javascript functions.php
- Child Theme Not Overriding Parent Theme
- How to enqueue JavaScript for specific WordPress pages only?
- Enqueue script o style only if a template part is loaded
- Enqueue styles after a plugin
- Enqueuing Script in functions.php vs on the page
- Relative path instead of absolute for wp_enqueue_script
- If is multiple page templates
- Register and enqueue style.css custom theme
- Enqueue scripts not working with if is page conditional tag in functions.php
- wp_is_mobile dequeue not working
- Why won’t my scripts load?
- How to insert html/css/javascript code to wordpress plugin
- Enqueue Style Only On Certain Pages Not Working
- Only let plugin add actions to wp_head & wp_footer on single posts
- enqueue styles for only mobile wp
- how to en-queue jQuery to load before the tag
- different style sheet for just one page template
- Scripts not loading when using the wp_enqueue_scripts action
- Custom Plugin – CSS works, JS doesn’t
- Split Media Queries in different files!
- Some questions about how proper add 2 CSS file in a WordPress theme?
- Why does get_template_directory_uri() not include “www”, only for enqueued stylesheets?
- Run a jquery script on on a certain template page
- enqueing Javascript and CSS
- Parent theme styles overriding child theme CSS [closed]
- I can’t add CSS with functions.php
- Proper Way to Load stylesheet on Condition
- How to load jQuery in TOP of wp_footer?
- get_template_directory_uri() links to child theme not parent
- Include Jquery libraries in wordpress theme?
- Page Template Won’t Load Correct CSS File
- wp_enqueue_script() not working
- Add custom css file after plugin css with WordPress Child Theme functions.php
- wp enqueue style on about us page
- How to reference different css (bootstrap) stylesheets for the header and body of a page?
- Test CDN link from function.php or wp_enqueue_script/style?
- CSS style and app.js not loading
- Stylesheet does not load despite functions.php
- Child Theme not loading multiple stylesheets
- I need to ‘wp_dequeue_script’ and ‘styles’ and ADD a bunch of other css and js
- Why is style.css not loading through the functions.php
- Javascript and Stylesheet in child page
- java script error Uncaught SyntaxError: Unexpected token ILLEGAL
- using enqueue_script in a shortcode isn’t working
- Bootstrap 4 Optimization
- Should I use `get_stylesheet_uri()` or `get_template_directory_uri()` when calling my CSS Stylesheet?
- wp_head not injecting css
- dynamically import array from another js file in WordPress
- Could the WP script/style loader be used to concatenate and gzip scripts and styles in the front-end?
- functions.php inject inline css
- Logout/login redirect CSS issue
- How to enqueue every script in a folder automatically?
- is_front_page not working in functions.php
- Is it possible to be more page/post specific with admin_enqueue_script?
- Defer all js except certain ones in functions.php file
- Properly applying nonce to a form using AJAX
- How to add background image control to page admin controls?
- Clean-up script tags
- wp_enqueue JavaScript in child-theme (ReferenceError) using Search & Go
- Add class or ID to any WordPress function
- Adding tawk.to code just before body tag on functions.php file
- Loading CDN that requires jQuery in WordPress
- Why does the ‘wp_nav_menu’ function work only until a menu is created?
- wp_register_script(… $in_footer = true) not working
- Enqueueing a script and a style sheet not working
- enqueue_script with filemtime javascript not working
- Is my code correct to enqueue CSS on a specific page?
- Not all CSS elements transferring via parent to child?
- wp_enqueue_script | Help me figure out what is causing jQuery is not defined
- Enable right click on WordPress site
- How to insert class in each list of categories?
- This code works, but the way I integrated it is breaking the media uploader. How can I integrate it properly?
- remove/hide wp-editor
- Creating a custom wordpress widget and stopping js from running twice(once in active widget once in widget selector)?
- Why is this function crashing my wordpress installation? [closed]
- colorbox not loading in
- Can we have conditional CSS styling?
- Bootstrap Integtration
- How to add javascript code into Divi child theme?
- function class doesnt work
- how to remove a tag in the_category function
- How To Display Author Popup on Entry Meta (Genesis Framework)?
- Adding a class to the body of an inactive site using multisite
- Conditionally apply css for a specific template part
- Random text changing to weird icons in both admin & front end
- Exclude javascript in certain page url and all following url’s after forward slash
- functions.php / replacing div’s with new ones?
- Why my wp_enqueue_script doesnt work on some page?
- How to fix enqueue_styles error for a twenty-seventeen childtheme
- Animated Accordion [closed]
- Can’t find function which is called in a wordpress theme
- Loading newest dependency javascript module file in functions.php