Script Modules #58618
Replies: 3 comments 8 replies
-
Hi there! Thanks for starting the conversation. All the feedback is vital for the people that is working in this project.
I tested with some use cases and this error appeard. For that reason, we print the import maps asap. before the modules and the preloads. If you coud test it too with more examples, that would be awesome. This file is the one that contains all the functions to register, enqueue and print a Module.
Thanks for the feeback, will take a look at it 🚀, feel free to add an issue or PR if you want to contribute too! |
Beta Was this translation helpful? Give feedback.
-
In this line: I see this reason:
Which makes sense - I think this is edge enough I suppose - modules have to be included in the footer for classic themes. |
Beta Was this translation helpful? Give feedback.
-
Here's one such discussion on cloudflare regarding rocketloader: |
Beta Was this translation helpful? Give feedback.
-
Hi Team!
Very excited about this project - a few things to think about for the new script modules/imports implementation.
I have implemented JavaScript modules in a few widely used plugins, so there are a couple things to note. None of these are blockers, but I thought maybe bringing them up now may help in some potential architectural decisions.
Script import maps need to happen first before any other
<script type="module">
on the page. If a script uses type="module" on the page, and it's printed before the import map, ALL scripts using the import will fail on the page. Ideally, the import map will output on the page before any potential scripts.JavaScript CDNS don't always play nice with javascript modules due to CORS issues. CORS headers need to be added, or they will get blocked. So if
@wordpress/interactivity
is served through a CDN, it won't work due to CORS issues. One specifically worth testing or reaching out to is bunny.net.Thanks team!
Beta Was this translation helpful? Give feedback.
All reactions