plicatibu Posted May 21, 2016 Share Posted May 21, 2016 Let tme say my game has many states but some are not frequently used. Instead they of download it wit all other JS files, I'd like to download them just when it were really needed. How could I implement this? Thanks. Link to comment Share on other sites More sharing options...
Rudrabhoj Bhati Posted May 22, 2016 Share Posted May 22, 2016 Why don't you just download the assets needed for them just when they are needed? Create separate load state to load assets specific to those states. I do not think you could download more JS code and then execute it, it would be a security nightmare for web browsers to allow such things. But may be there might be a way to download JS files of those states in a variable and then eval it lol But ultimately, it'll hardly save you few KB. Link to comment Share on other sites More sharing options...
plicatibu Posted May 22, 2016 Author Share Posted May 22, 2016 Thanks for replying. I already separated assets in different states. But I'd like to avoid downloading unneeded states upfront because many places here in Brazil you have 2G connection only. It could make a big difference for those using such slow Internet connections. Link to comment Share on other sites More sharing options...
Rudrabhoj Bhati Posted May 23, 2016 Share Posted May 23, 2016 Use different loading states too. Main loading state should load only the required assets. There be another loading screen to load assets for the levels who are less used. Link to comment Share on other sites More sharing options...
Recommended Posts