Make WordPress Core

Changes between Version 2 and Version 3 of Ticket #12009, comment 100


Ignore:
Timestamp:
07/14/2025 09:27:52 PM (7 months ago)
Author:
westonruter
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #12009, comment 100

    v2 v3  
    1111> Yea, printing inline scripts with `text/template` type seems pretty "hacky" imho. Lets avoid that even if it means that `defer` scripts will not support "after" scripts (`async` scripts shouldn't be in the script-loader at all imho, see above).
    1212
    13 I don't think we can avoid `after` scripts entirely, as then an author can't reliably execute some code when the script loads (without resorting to a [https://async-script-load-listeners.glitch.me/somewhat hacky `MutationObserver` solution]). I'm referring to `defer` scripts specifically, since the order of inline scripts for `async` should not be significant. To me it boils down to two options, to whether for `defer` scripts:
     13I don't think we can avoid `after` scripts entirely, as then an author can't reliably execute some code when the script loads (without resorting to a [https://westonruter.github.io/async-script-load-listeners/ somewhat hacky `MutationObserver` solution]). I'm referring to `defer` scripts specifically, since the order of inline scripts for `async` should not be significant. To me it boils down to two options, to whether for `defer` scripts:
    1414
    15151. We handle the deferred execution of `after` inline scripts using the current approach of `wpLoadAfterScripts()` with its `text/template` transformation.