Search code examples
javascriptnode.jsminifyuglifyjs

Failed to load large JavaScript file ExpressJS after uglifying


All my scripts are compressed and minified used uglifyJS:

minify all files

The size of this file "app.min.js" is 982.1KB however when I tried to run the node server and open the app in the browser It's stopped in 502kB

running the server

and after some while

enter image description here

I don't know what happened there, Is there any limitation on Javascript file '502kB' ? what I miss


Solution

  • I think this article may help you, it is all about nodejs server serving static content, so nginx is recommended to do this purpose.

    If you have to use nodejs server then you should make all files smaller in terms of size, no need for example to minimize libraries files as jquery since it is already minimized, scripts should be minimized only, you can even minimize all libs files into one javascript file called libs.min.js as example and the rest of your scripts in another file called script.min.js.