I am trying to execute a function which is dynamically fetched, but I am getting an undefined error. I think it probably has something to do with scope but I don't know the exact problem.
This is code.
<button onmouseover="function load_script(){import('/script.js')};load_script()" onclick="checker()">Click
The script file is located at root and has these contents.
export const checker = () => console.log(2020);
The browser does fetch the script upon mousehover but it cannot find the function checker
on click event which makes me think this problem is related to scope but I can't resolve it.
Any ideas?