-
Notifications
You must be signed in to change notification settings - Fork 139
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
Reference pages with multiple examples load p5 multiple times #770
Comments
Hey @davepagurek , i tried adding a simple check
it did solve the issue is it okay , or it is forcefully checking the script tag ? |
Sounds good @webermayank! I think it's still true that we don't need the script tag at all on the main page since we don't actually use it there, just for caching, but this fix seems straightforward and fixes the main problem. Feel free to make a PR! |
@davepagurek , should i make PR to |
If you go to the live non-beta site and open the dev tools element inspector, do you see multiple script tags there too? if so, we can make the change on main, and I can copy the change to the 2.0 branch as well once it's merged. |
Yes https://p5js.org/reference/p5/arc/ also have multiple script tag , so i will make PR to main branch. |
@webermayank The current code change looks good and effectively prevents duplicate <script> tags by checking if the p5ScriptTag already exists nice work! |
Most appropriate sections of the p5.js website?
Reference
What is your operating system?
Mac OS
Web browser and version
Firefox
Actual Behavior
If you open https://beta.p5js.org/reference/p5/arc/ and inspect element, the head tag has multiple p5 scripts:
Each example in the p5 reference loaded in an
<iframe>
tag with the following source:p5.js-website/src/components/CodeEmbed/frame.tsx
Line 31 in 8e571e8
It might be because of this:
p5.js-website/src/components/CodeEmbed/index.jsx
Line 70 in 8e571e8
<script>
tag is created on the main page (this triggers the browser/service worker to cache its contents) and then the contents is fetched (which uses the cache) and sent to each example here:p5.js-website/src/components/CodeEmbed/frame.tsx
Line 134 in 8e571e8
id
already exists on the page and only make a new tag if it's not already there?fetch()
cache it?)Expected Behavior
iframe
s.Steps to reproduce
Open https://beta.p5js.org/reference/p5/arc/ and inspect element, then look at the head tag
Would you like to work on the issue?
Someone else can take this!
The text was updated successfully, but these errors were encountered: