Make WordPress Core

Opened 17 years ago

Closed 16 years ago

#11944 closed defect (bug) (duplicate)

Allow wp_enqueue_script() after wp_head()

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

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
17 years ago

+1 for this.

Some discussion ​here, ​here, and ​here.

#2 @TobiasBg
17 years ago

  • Cc wordpress@… added

huge +1

#4 @scribu
16 years ago

  • Milestone Future Release
  • Resolution → duplicate
  • Status new → closed
Note: See TracTickets for help on using tickets.