Make WordPress Core

Opened 15 years ago

Closed 14 years ago

#11944 closed defect (bug) (duplicate)

Allow wp_enqueue_script() after wp_head()

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

Description

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', ...);
  wp_print_scripts('handle');
}

Change History (4)

#1 @archon810
15 years ago

+1 for this.

Some discussion here, here, and here.

#2 @TobiasBg
15 years ago

  • Cc wordpress@… added

huge +1

#4 @scribu
14 years ago

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