CoolBus's avatar

Handling multiple files with duplicate dependancies with mix/webpack

Hello,

I'm looking to include split up the javascript files mix generates. I've got an app that uses plotly.js (a fairly sizeable JS library) and it doesn't make sense to include this on every page.

I've separated plotly.js and my own custom code around handling the graphs into another mix.js declaration in my webpack.mix.js file, but the file that's generated contains the jQuery library (which is loaded elsewhere).

Can anyone point me in the right direction for using mix to generate multiple js files without having duplicate dependencies?

Any help is much appreciated, thank you.

0 likes
2 replies
criptopus's avatar

I have the same problem, did you find a solution?

Tray2's avatar

@criptopus It really doesn't matter that much, the js is cached in the browser. and will be loaded just once from the server. If you are concerned about memory usage, well then you probably wouldn't use a jQuery or any other framework for your js, since you will always load a lot of overhead, that you never use.

The easiest way to achieve what you want is to not use any transpiller and then include what you need for each page.

Please or to participate in this conversation.