How to add external JS on index.html in React boilerplate?

1.6k Views Asked by At

I am new in React JS. I have started with React Boilerplate.
I have a js file and want to use that file globally, so whenever I was trying to add a js file with script tag <script src='' type='text/javascript'></script> in index.html, it throwing an error

Uncaught SyntaxError: Unexpected token <.

So any suggestion?

Note: Import js file in each component is working but I don't want to include it in every component repeatedly. I don't have any knowledge on webpack.

1

There are 1 best solutions below

0
On BEST ANSWER

You can put JS File in assets folder, then import it in App.js

import ExternalJS from '../assets/externaljs.js';

This will be available in index.js.