Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Optimization Detective by default on the embed template #1472

Merged

Conversation

westonruter
Copy link
Member

I was doing some testing with post embeds and I tried embedding a post embed from my blog onto my local test environment. When I did so, I saw an error in the console:

Access to script at '.../detect.js?ver=0.4.1' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Normally the embed template doesn't have any external scripts, but since Optimization Detective is running on my site it is adding a script module to the page that does a dynamic import of detect.js. This then is causing an error because the WordPress post iframe is served with sandbox="allow-scripts" which doesn't include allow-same-origin, meaning the Same-Origin Policy is being enforced, blocking the loading of the script (as I understand).

The solution is simply to disable Optimization Detective for the embed template. In reality there is not really a need for optimizations to run on the basic embed template, as there is at most only one or two images and everything is in the viewport. WordPress core is already adding fetchpriority=high to the featured image in a post embed template.

@westonruter westonruter added the [Type] Bug An existing feature is broken label Aug 14, 2024
Copy link

github-actions bot commented Aug 14, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: westonruter <[email protected]>
Co-authored-by: swissspidy <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@westonruter westonruter merged commit bc37748 into trunk Aug 14, 2024
19 checks passed
@westonruter westonruter deleted the update/disable-optimization-detective-on-embed-template branch August 14, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature is broken
Projects
Status: Done 😃
Development

Successfully merging this pull request may close these issues.

2 participants