With ES Modules, you can natively import other JavaScript. Like confetti, duh: import confetti from ‘https: //cdn.skypack.dev/canvas-confetti’; confetti(); That import statement is just gonna run. There is a pattern to do it conditionally though. It’s like this: (async () => { if (condition) { // await import(“stuff.js”); …
Dynamic, Conditional Imports
Full Disclosure: This webpage may contain affiliate links, in which the website owner would receive a commission for purchases made. This does not affect your purchase cost.