[SOLVED] The load event to check the document load

Hi!

I make the game menu using html and css, and I have a question. Does playcanvas use the load event to check the loading of all style elements, images, or should I implement the verification condition myself?

If the images are in the asset register and are set to preload, then yes.

If they are linked externally, then no.

I have two scripts that are configured to load html and css code. The script, which is responsible for loading css code, has two attributes. The first is a .css file, the second is a image. .css file and image also configured to preload. However, when you start the application, the image is not displayed immediately. It turns out that I need execute the load event?

That sounds odd. If the images is set to preload, it should be done by the time the app starts.

Can you share the project or replicate this in a new public project please?

Yes, I can provide a link to the project, but a little later, because the project is large and it takes time to reproduce this fragment. :grinning:

I reproduced the problem in this scene. I also noticed that this problem occurs only in the Mozilla Firefox browser, in other browsers everything works correctly. The problem is presented in this video, where you can see that after loading the scene, the viewport and the gray background are displayed. This happens quickly, but on weak devices it can be very noticeable.

It might be the delay between the app starting and initialize being called on the script. If it was an image load problem, I would expect to see the text input field before he background image loads.

If you have an ORG account, I think it might be better to add the DOMs there before the app starts/as part of the loading screen.

1 Like

Unfortunately, I do not have an organization account, but I will think about it. I am developing a new version of the menu and use the background style property to set the background. In this case, everything works correctly in all browsers. I think I’ll stop on this option for now. Thanks for the help! :slightly_smiling_face: