wp_enqueue_scripts, wp_register_scripts, wp_print_scripts: i’m confused

wp_print_scripts is the action that runs when scripts are output to the template. wp_register_script and wp_enqueue_script are functions for registering/enqueueing scripts to be output when wp_print_scripts runs.

you can’t register or enqueue styles in the wp_print_scripts action hook because styles have already been output in the wp_print_styles hook, which runs before wp_print_scripts.

refer to the action reference to see the order things are executed in in a request:

22. wp_head
23. wp_enqueue_scripts
24. wp_print_styles
25. wp_print_scripts

Leave a Comment