Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
Usage of import('something') vs. import from 'something'

I came across the following from MDN:

var promise = import("module-name");

Is this deprecated, or when would that ever be used? I'm only familiar with the syntax of:

import promise from 'module-name';
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The following is a static import:

import module from "module-name";

It's statically resolved, before any code is executed.

This is a dynamic import:

const promise = import("module-name");

The reason why it's named promise is because import(...) returns a promise that resolves to the imported module (errors if module not found).

So you can use it like this:

import("my-mod").then((myMod) => {
    myMod.func();
});

Or the more preferred async/await syntax:

const myMod = await import("my-mod");

myMod.func();

Dynamic imports are executed and resolved at runtime which is why you must wait for it to complete. They're commonly used for code-splitting, lazy loading, or importing modules when needed (plugins could be an example).

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!