Thursday, April 16, 2026

Dynamic Import in Javascript

 

Dynamic Imports
If you need to load a function conditionally or on-demand (e.g., inside an if block or an event listener), use the import() function. This returns a Promise.

// Using .then()
import('./myFile.js').then((module) => {
  module.myFunction();
});

// Using async/await
const module = await import('./myFile.js');
module.myFunction();

No comments:

Post a Comment

LLM Quantizations

Quantization in Large Language Models (LLMs) is a compression technique that reduces a model's memory footprint and comp...