Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#11944 closed defect (bug) (duplicate)

Allow wp_enqueue_script() after wp_head()

Reported by: scribu Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords: needs-patch
Focuses: Cc:


Say you have this code:

function my_template_tag() {
  // output some stuff here

  wp_enqueue_script('handle', ..., $in_footer = true);

It should just work, even if it's called after wp_head().

Currently, you have to do something like this:

function my_template_tag() {
  // output some stuff here

  add_action('wp_footer', 'my_template_tag_script');

function my_template_tag_script() {
  wp_register_script('handle', ...);

Change History (4)

#1 @archon810
6 years ago

+1 for this.

Some discussion here, here, and here.

#2 @TobiasBg
6 years ago

  • Cc wordpress@… added

huge +1

#4 @scribu
5 years ago

  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.