1

I have imported an object from a JS file to another JS file, using import/export keywords.

This forced me to give the linked script in the HTML the propertie :

<script type="module" src="modules/test.js"></script> //exported object
<script type ="module" src="Wallet.js"></script> //imported object

Now , I have noticed that when I do this , many functions from the imported file stop working and the HTML events that rely on JavaScript are never read.

Suddendly I have errors , like " Function is X is not defined at HTML.element.onmouseover"

I know this was working before and stopped when I introduced the import/export and module type.

What is the reason for that?

izzypt
  • 170
  • 2
  • 16
  • 1
    See https://stackoverflow.com/a/59539045 - inline handlers may only reference global variables, but code inside ES6 modules runs in its own private scope. Best solution: never use inline handlers, they're universally considered to be quite poor practice – CertainPerformance Mar 20 '21 at 13:50
  • Oh wow , thank you! I get it now – izzypt Mar 20 '21 at 13:52

0 Answers0