# ES6 Redundant Imports

**URL:** <https://forum.babylonjs.com/t/es6-redundant-imports/37326>\
**Category:** Tutorials and tips\
**Tags:** es6\
**Created:** [January 12, 2023, 3:41pm UTC](https://forum.babylonjs.com/t/es6-redundant-imports/37326 "2023-01-12T15:41:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Takemura](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/takemura/32/25836_2.png) [@Takemura](https://forum.babylonjs.com/u/Takemura)\
**Post date:** [January 12, 2023, 3:41pm UTC](https://forum.babylonjs.com/t/es6-redundant-imports/37326/1 "2023-01-12T15:41:46Z")

</div>

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 this.game.constants instead of just constants.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [January 12, 2023, 9:31pm UTC](https://forum.babylonjs.com/t/es6-redundant-imports/37326/2 "2023-01-12T21:31:04Z")

</div>

> [@Takemura](#):
>
> What I wonder is if the multiple es6 imports of constants.js does affect loading time?

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)

---

<div class="post-metadata">

**Author:** ![Takemura](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/takemura/32/25836_2.png) [@Takemura](https://forum.babylonjs.com/u/Takemura)\
**Post date:** [January 13, 2023, 9:23am UTC](https://forum.babylonjs.com/t/es6-redundant-imports/37326/3 "2023-01-13T09:23:50Z")

</div>

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