Skip to content

Detect and warn when p5.js is included multiple times - #9421

Merged
limzykenneth merged 3 commits into
processing:mainfrom
limzykenneth:duplicate-import
Nov 27, 2026
Merged

limzykenneth merged 3 commits into
processing:mainfrom
limzykenneth:duplicate-import

Conversation

@limzykenneth

@limzykenneth limzykenneth commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Resolves #7687, closes #7791

Changes:

Detect when window.p5 is already defined and halt global mode initialization if that is true to avoid duplicate p5 sketches or unintended error. Also prints a warning message.

Also normalize internal addons registrations. This does not prevent the addons from being registered, resulting in double registration, the behavior here could result in weird and unintended effects in sketches but the idea is that the above warning message will prompt the user on the real fix which is remove the duplicate script tag.

@VANSH3104 if you can do have a try with this build to see if it works for you as well. Thanks.

PR Checklist

@p5-bot

p5-bot Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

@VANSH3104

Copy link
Copy Markdown
Member

@limzykenneth Yup, I checked it locally. It's working as expected, and the warning is also logged in the console. Thanks!

@limzykenneth
limzykenneth merged commit b9e2b3b into processing:main Nov 27, 2026
5 checks passed
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.

[p5.js 2.0 Beta Bug Report]: Output a friendly error when p5 is loaded twice on a page

2 participants