Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#44709 closed enhancement (duplicate)

Allow for late loading of scripts added via wp_add_inline_script()

Reported by: woodent Owned by: woodent
Priority: normal Milestone:
Component: Script Loader Version: 4.5
Severity: normal Keywords:
Cc: Focuses:

Description

Inline scripts added via wp_add_inline_script() are only output when the referenced script file is loaded. If an inline script is added after a referenced script file has already been output, the inline script won't be output.

Much like how wp_enqueue_script() can be used within a shortcode to enqueue a file in the footer even though it would normally be loaded in the head; I propose that wp_add_inline_script() should output the inline script even if the referenced script file has already been loaded.

Since we can't predict when a script file that was loaded in the footer might be loaded into the head due to a third-party script with it as a dependency, wp_add_inline_script() should also be flexible and not break things by simply not outputting the code in those cases.

Change History (1)

#1 @ocean90
8 years ago

  • Keywords dev-feedback needs-patch removed
  • Milestone Awaiting Review
  • Resolutionduplicate
  • Status assignedclosed

Duplicate of #41990.

Note: See TracTickets for help on using tickets.