0

Is there any way in javascript or react to load a script inside the index.html and then import that loaded script in another file?

index.html
  <body>
    <script
      type="text/javascript"
      src="http://localhost:3001/myService.js"
    ></script>
    <div id="root"></div>

  </body>


anyOtherComponent.js
import myService from "  ";

Any suggestions are welcome.

Pep
  • 647
  • 6
  • 20
  • Does this answer your question? [ES6: import module from URL](https://stackoverflow.com/questions/34607252/es6-import-module-from-url) – Jeff B Apr 06 '21 at 18:01

1 Answers1

1

In short, not really. Your best bet is to download the file in question.

Please refer to this answer as well:

ES6: import module from URL

Jeff B
  • 975
  • 8
  • 25