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?
- How can I get a list of all enqueued scripts and styles?
- WordPress Enqueue for homepage only, functions.php, wp-framework
- How to add stylesheets only to pages with specific shortcode?
- wp_enqueue_scripts, wp_register_scripts, wp_print_scripts: i’m confused
- functions.php inject inline css
- Where and how to put inline js in pages
- Why I can’t add a CSS style in this WordPress theme?
- deregister scripts on certain page
- Does WordPress Development Mode Exist (with not minified JS)?
- Enqueue Script with data attributes
- How do I create a new WP admin color scheme?
- How can I dequeue a Plugin Stylesheet?
- Use wp_enqueue_scripts, not wp_print_styles?
- Logout/login redirect CSS issue
- How to enqueue every script in a folder automatically?
- Apply jquery script to only woocommerce product pages and categories
- Add attribute to link tag that’s generated through wp_register_style?
- is_front_page not working in functions.php
- How do I load custom scripts and styles for a page?
- Most elegant way to enqueue scripts in function.php with foreach loop
- wp_register_script not loading as expected
- Problem using is_single() to enqueue script from functions.php
- Remove “says” from comments
- How to add CSS style sheet dynamically in wordpress
- Enqueue less file not working in child theme?
- Simple/basic use of get_current_screen
- I created a child theme and it doesn’t work for some of the css files
- Is it possible to be more page/post specific with admin_enqueue_script?
- Run Product Filter Javascript On Page Template
- CSS stylesheet not loading
- Enqueued Stylesheets Effecting Admin Styles
- wp_enqueue_script + how to load JS or CSS in one URL merge call?
- Defer all js except certain ones in functions.php file
- How to override enqueued styles using a child theme
- Prevent CSS/JS loading when plugin is not used
- Dequeue script in template isn’t working
- Move all the JS files to the bottom|footer, the right way
- Properly applying nonce to a form using AJAX
- How to add background image control to page admin controls?
- Clean-up script tags
- Search user metadata with checkboxes via ajax (almost working)
- wp_enqueue JavaScript in child-theme (ReferenceError) using Search & Go
- Why is my Gutenberg block returning an error after initial save?