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

change load order preload method #3536

Open
stalgiag opened this issue Feb 25, 2019 · 5 comments
Open

change load order preload method #3536

stalgiag opened this issue Feb 25, 2019 · 5 comments

Comments

@stalgiag
Copy link
Contributor

This feature request is based on the discussion in #3347.

Essentially some users may want a p5 sketch to load first when used as an element on a page with a high number of external assets. @calebegg proposed that this could be achieved by initializing p5 with the DOMContentLoaded event rather than the load event which is the current default.

Here is a visual explanation of the difference between the two events..

What do people think about this as a feature?

@vedhant
Copy link
Contributor

vedhant commented Mar 13, 2019

@stalgiag I feel we could use DOMContentLoaded if the sketch is independent of the entire webpage. It would make the sketch load much faster.
However if the sketch requires, for example, an image to load then onload will have to be used.
How do you suggest we incorporate both?

@limzykenneth
Copy link
Member

I'm thinking it would either be explicit or implecit.

Explicit meaning that we choose as a default DOMContentLoaded but if a user wants some assets to have already loaded, they would need to specify in some way for the library to use onload instead.

Implicit would mean that we will need to somehow detect which case would be the best, such as if the user have code that references assets in the DOM then uses onload and vice versa.

@stalgiag
Copy link
Contributor Author

Yes @limzykenneth I was suggesting something explicit but if anyone has any thoughts on how it might be done implicitly that would be really neat. I am not sure how that detection could be written.

@limzykenneth
Copy link
Member

I have no idea either about how to implement the implicit one (not off the top of my head anyway) but I feel that the explicit route may be a bit much for a beginner to handle if the default is DOMContentLoaded.

@Spongman
Copy link
Contributor

i would recommend retaining the current default and adding an explicit switch (maybe p5.useDOMContentLoaded = true' ?) for those that are aware of the caveats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Proposal
Development

No branches or pull requests

5 participants