Best practice to import three.js

Hi,
My project uses three.js everywhere and I use import * as THREE from 'three' many times. Maybe twenty files import THREE in my projects.
Is it proper to import three so many times? Does it cost much memory? And need I do something to “clear” three module when I dispose things to free the memory?

1 Like

Yes. If you use three.js in different modules, you also have to perform the respective imports. When you create a bundle of your source files, build tools will ensure that any imported modules are not included multiple times in the build. Besides, them same is true when using ES6 modules in JavaScript which is embedded in HTML pages. Browsers ensure to load modules only once.

2 Likes