Webpack css js execution order

if css and js are packaged into a js file, how to ensure that the internal real js logic is executed after css rendering.

Mar.28,2021

this has nothing to do with webpack. This is part of the browser's rendering strategy.

when rendering HTML, the browser will block if it encounters css or js (meaning no asynchronous attribute is added), and then download and perform the rendering.

so to implement your js logic is to execute after css rendering,
just put js after css.

if you are using the webpack plug-in html-webpack-plugins, you can configure the order in the template (the default is js after css).

Menu