I have a website made in ReactJS. In public/index.html
, I have
<head>
<script src="/lib/analyzejs-v1.js"></script>
<script src="/lib/analyzejs-v2.js"></script>
</head>
<body>
<div id="root"></div>
</body>
where analyzejs-v1.js
has 6Mo, and analyzejs-v2.js
has 3Mo; they are all fixed files that I could not much modify.
These two files are not modules; their functions are declared (e.g., declare function f1(address: string): string;
in src/defines/analyzejs-v1.d.ts
). So some components call functions of analyzejs-v1.js
by using a function name like f1(...)
directly without any namespace, import, or export. And the rest of the components call functions of analyzejs-v2.js
by using a function name like f2(...)
directly without any namespace, import, or export.
It takes time to load these two js library files. So I'm looking for a way to load either analyzejs-v1.js
or analyzejs-v2.js
according to the component (or URL).
So does anyone know a conventional way to load different JS library files for different components?