ES6 Redundant Imports

Hello all,

I wanted to reorganise my project and now I wonder which would be the correct approach.
Lets say you have a classes Game, Database, Menu etc.
Currently I do import constants.js (inherits game measures like map size and building/unit constants) into every class that needs it. A different approach I used on language, which is currently just set by this.language = { 1:‘Welcome’, … }. The Database class is also used by server, not only client-side.

What I wonder is if the multiple es6 imports of constants.js does affect loading time? So would it be faster to import just once and set i.e. on Game or Database: this.constants = constants. This would make accessing slower, because on a class I would have to use instead of just constants.

No worries they would be dedup and usually ends up being a pretty minimalistic overhead I would not worry about (basically the import transpilation only)

1 Like

Thanks for the reply. I will also create language.js now :slight_smile: