M
M
Mykola2022-04-15 13:16:00
JavaScript
Mykola, 2022-04-15 13:16:00

How to load a remote JS script with further use in Webpack?

There is a certain set of user-defined functions that have been combined into a script. Inside this script is purely a set of ordinary functions that are interconnected.

At the moment it is loaded directly into the DOM in order to use its functions:

<html>
    <body>
        <script defer src="http://some-site/api.js?v=1.1.0"></script>
        <script>
            document.addEventListener('DOMContentLoaded', function () {
                someFunctionFromApi();
            }, false);
        </script>
    </body>
</html>


IMPORTANT : There are other projects using this remote script that don't yet have webpack.

How can it be loaded into Webpack so that it continues to work for others as a normal "text/javascript"?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question