[wp-trac] [WordPress Trac] #62435: Preload script modules and enqueue script modules in wrong order

WordPress Trac noreply at wordpress.org
Fri Nov 15 19:41:25 UTC 2024


#62435: Preload script modules and enqueue script modules in wrong order
---------------------------+------------------------------
 Reporter:  yogeshbhutkar  |       Owner:  (none)
     Type:  defect (bug)   |      Status:  new
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Script Loader  |     Version:  6.5
 Severity:  normal         |  Resolution:
 Keywords:  has-patch      |     Focuses:
---------------------------+------------------------------

Comment (by jonsurrell):

 Hello, and thanks for the report!

 First, I'd like to clarify. Is there a bug that's been observed or is this
 describing a hypothetical race condition that //could// lead to a bug?

 I don't believe there's an issue with the ordering, but if there's a
 reproducible bug I'd like to investigate further. Modules work very
 differently from "classic" scripts.

 The [https://developer.mozilla.org/en-
 US/docs/Web/HTML/Attributes/rel/modulepreload modulepreload] that are
 mentioned are a included for performance reasons, they are not strictly
 necessary. If they are removed the JavaScript modules should continue to
 work without issue. Module preloads do not cause JavaScript to be
 executed, they fetch the referenced modules and prepare them for use.

 If the preloads are removed, the modules will still fetch their
 dependencies, but it may happen later because the browser will need to
 discover, fetch, and process the dependency modules inside the JavaScript
 modules themselves.

 I believe ordering as they are (enqueued modules first, preloads second)
 are because the enqueued modules are higher priority. They're the main
 modules that are expected to be executed when the page is loaded. The
 preloads hint at the dependencies that will be statically required so that
 the browser can also fetch them and get them ready (before discovering
 them in JavaScript source).

 Please let me know if I misunderstood this ticket or there are more
 details!

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62435#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list