Use webpack to control loading order


I want to use Webpack to control the loading order of my js files, so they load in the determined order and I don’t have to order all of them in a sequence of tags.

The js files that I have to control are these, in the order I need them to load:

  • jQuery (in a local file)
  • jQuery UI (in a local file)
  • Solution API (minified)
  • Reqwest (must be included after the API)
  • UI files

The project that I am working on is not a Node project, so I would prefer not to get jquery and the others from Node modules, but from the local files.

Here is what I want to do, without using Webpack:

<script language="javascript" src="./js/libs/jquery.min.js"></script>
<script language="javascript" src="./js/libs/jquery-ui.min.js"></script>
<script language="javascript" src="./js/libs/Api.min.js"></script>
<script language="javascript" src="./js/libs/reqwest.js"></script>
<script language="javascript"  src="./js/UI.min.js"></script>

How can I reproduce the same behavior, as if all the scripts were loaded on the HTML page, but using Webpack?

Link: Use webpack to control loading order
Source: Stack Jquery


About Author

Leave A Reply