Hello
Just a quick question I have:
Is it better practice and optimisation to have more scripts for different things (e.g. a player entity has a jump script, crouch script all individual) or better to keep it inside 1 big script? Will more scripts = bad optimisation?
Or does it make no difference?
Thanks
Hi @nasjarta,
As far as loading times are concerned PlayCanvas can concatenate all script files in a single one, so having many of them isn’t a problem.
As far as good coding practices and JS performance I’d say having multiple script isn’t a problem, on the contrary it can help with maintenance and controlling large code bases.
Usually you’d keep everything in a single script when you are doing heavy processing like a render loop, where every method call matters e.g. preparing a vertex buffer per frame for instancing.
Hope that helps!
4 Likes