D
D
Dmitry2016-03-07 03:47:53
JavaScript
Dmitry, 2016-03-07 03:47:53

Preloader for js files. How to show loading animation until js files are loaded?

In my threejs, models in js format are loaded.
I need to hide the scene until the models are fully loaded

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stalker_RED, 2016-03-07
@Stalker_RED

The script tag has an onload event.
In the simplest version, it is enough to make a counter, in which to place the number of requested resources, and hang a handler on onload, with the decrement of the counter. If it reaches zero, everything is loaded.

A
Anton Shcherbakov, 2016-03-07
@WestTrade

Alternatively, load the main JS files. After the event onload / $(document).ready - load large files with models via AJAX.
Thus, you will kill several birds with one stone: the user does not have to wait for the page to fully load, he sees the preloader and understands that he needs to wait more; you will be able to control the download state, "if loaded and connected - then".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question