Webpack Optimization of Minification

Asked

Viewed 50 times

2

I’m starting with the Webpack and I’m learning how to work Config of it, and I’ve seen some of the documentation that deals with Resolve.extentions, I found it really cool because you can hide the extensions. But it came to mind: In my Extensions I put for example:

import 'jquery/dist/jquery.min.js'

In this case now I put only:

import 'jquery/dist/jquery'

And it works great. Great. But he’s getting the .js, and not the minified file. It makes some difference in terms of performance he catch the .js or .min.js? How does Webpack treat this type of file? You have to put some Priority for him to catch first the .min.js ?

1 answer

1


Does it make any difference in terms of performance he catch the . js or .minjs.?

Yeah, it makes a lot of difference. The minified file, as its name says, is smaller, and this generates performance difference when the site will load the dependencies, because a smaller file is loaded and interpreted faster.

You have to put some Priority on it to get the .min.js first. ?

You can put in the configuration of resolves.Xtensions, something similar to:

resolve: {
  extensions: ['.min.js', '.js']
}
  • Perfect Lucas! So it means that the extensions that you will put first, are the ones that will be prioritized?

  • Exactly @Jackson!

  • Great Lucas, thank you so much :) ! I’ll take advantage and already put my minified CSS in priority as well ;)

  • 1

    For production is the most suitable, for the best performance. Only for development that may not be, because the minification process renames all variables and removes spaces, making it difficult to debug.

  • Yeah, that I know Lucas, I got one if NODE_ENV== Production. Anyway it is for those who come to visit my question! Thanks =)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.