Electron: do I need to import libraries in HTML instead of javascript?

  electron, html, import, javascript

I’m learning Electron, creating a simple 3D visualiser based on three.js.

I stumbled upon an issue: the guide I’m following (here) copypastes the three.js library inside the project directory and includes it in the main HTML file with a script tag.

Coming from a Python background this strikes me as very annoying since:

  1. I’d need to manually copypaste this into every project that requires three.js;
  2. If I want to use a different version of the library I have to copypaste it again.

Is there an alternate way to import three.js that doesn’t require me to directly type its path in the HTML file? Or is there a good reason why imports are done this way? I tried looking for a similar answer but couldn’t find any, maybe I don’t know exactly what to search for.

Source: Ask Javascript Questions

LEAVE A COMMENT