Answer the question
In order to leave comments, you need to log in
Is it possible to choose what to load inside a module?
I want to choose which script to load
if(true){
import { OrbitControls } from './s/OrbitControls.js';
}
SyntaxError: Unexpected token '{'
Answer the question
In order to leave comments, you need to log in
It is forbidden. The import statement is only allowed at the top level, outside of conditions and functions.
There is a dynamic import.
https://learn.javascript.ru/modules-dynamic-imports
https://developer.mozilla.org/ru/docs/Web/JavaScri...
https://habr.com/ru/post/455200/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question