Skip to content

Enforce sync JS#18559

Draft
timkelty wants to merge 4 commits into4.xfrom
bugfix/enforce-sync-js
Draft

Enforce sync JS#18559
timkelty wants to merge 4 commits into4.xfrom
bugfix/enforce-sync-js

Conversation

@timkelty
Copy link
Copy Markdown
Contributor

@timkelty timkelty commented Mar 13, 2026

Summary

  • Load appended scripts sequentially via native script insertion.
  • Remove the unused app/resource-js fallback.

Why

CP resources may be served from a CDN on another domain. Without this change, appended dependent scripts can execute out of order for cross-domain requests.

Example:

<script src="https://cdn.craft.cloud/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/build/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/cpresources/vendor.js"></script>
<script>window.App.init();</script>

window.App.init() can run before vendor.js finishes loading.

Previous fix

The earlier app/resource-js fallback was introduced in 1a958a7. It could appear to help because it converted cross-domain CP resource URLs into same-origin requests, keeping jQuery on its same-origin script-loading path. But the append flow still relied on jQuery's script handling, so execution order for dependent appended scripts was not guaranteed.

Relevant jQuery issues:

This PR preserves ordering explicitly and removes that fallback path.

Related issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant