-
Notifications
You must be signed in to change notification settings - Fork 509
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
Demos on 2D Collision Detection page are not working due to external script not loading #9346
Comments
@caugner This needs to move to yari repo. CORS blocks use of https://cdnjs.cloudflare.com/ajax/libs/crafty/0.5.4/crafty-min.js. There is nothing an author can do except use another library. Not sure what the solution is - short term perhaps could add the hash for this particular case to the script-src for MDN/play: Longer term - add a way for trusted authors to set the hash? Thoughts? |
PS, thanks @pano9000 ! |
Same problem but different library here #9359 Implies we need a dynamic way to specify in examples that certain hashes are trusted. |
It looks like a timing issue, i.e. Crafty seems to be loaded only after it is used: I don't see any evidence of a CSP issue, but maybe that part of the issue has been resolved in the mean-time. However, maybe this issue is related to #9324. |
@caugner You are right that this is not a CSP issue. Thank you! I can get this to work by moving script creation into the javascript and running the code on the load event (as per details twistie below) But IMO this still indicates a bug in Yari. The HTML is loaded like this which should be blocking: <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/crafty/0.5.4/crafty-min.js"></script> In MDN this is late loaded, hence the error. If you copy the same source into an HTML file it works fine. const scriptElement = document.createElement("script"); scriptElement.setAttribute( "src", "https://cdnjs.cloudflare.com/ajax/libs/crafty/0.5.4/crafty-min.js", ); scriptElement.setAttribute("type", "text/javascript"); scriptElement.onload = craftyLoaded; document.body.appendChild(scriptElement); |
Sorry, my bad, I tested it wrongly. #10714 is also fixed and doesn't show the error any more. |
Thank you @pseudopilot, it looks indeed like this was fixed by #11017. 🎉 |
MDN URL
https://developer.mozilla.org/en-US/docs/Games/Techniques/2D_collision_detection
What specific section or headline is this issue about?
No response
What information was incorrect, unhelpful, or incomplete?
The demos based on the external "crafty" JS lib are not playable, because the "crafty" script seems to get blocked by CORS. The console then shows "ReferenceError: Crafty is not defined".
Happens with Firefox 114.0.2 and Chrome
What did you expect to see?
The demo should be playable
Do you have any supporting links, references, or citations?
No response
Do you have anything more you want to share?
No response
MDN metadata
Page report details
en-us/games/techniques/2d_collision_detection
The text was updated successfully, but these errors were encountered: