Dynamic import()
Në shqip: Importi dinamik
ShpjegimiSQ
import("./modul.js") ngarkon një modul vetëm kur të duhet dhe kthen një promise. Bundler-at e ndajnë kodin automatikisht, kështu faqja ngarkohet më shpejt.
EnglishEN
import("./module.js") loads a module only when needed and returns a promise. Bundlers split the code automatically, so the page loads faster.
Si ta mendosh
Si t'i marrësh librat nga biblioteka vetëm kur të duhen.
Lexoje në anglisht
Like borrowing books from the library only when you need them.
Shembull kodijavascript
butoni.addEventListener("click", async () => {
const { hapGrafikun } = await import("./grafiku.js");
hapGrafikun();
});