Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

magmatic's avatar

What's the recommended way to include a JS library?

I installed a JavaScript library using npm called jquery-timepicker. I want to use it on one of my pages, but not all of them.

It got installed to /node_modules/jquery-timepicker

I manually added a couple of mix.copy(...) lines to webpack.mix.js. When I ran "npm run dev", this copied the appropriate files from that library from "/node_modules/jquery-timepicker" to "/public/node_modules/jquery-timepicker". In my page code, I include them the usual way with and that works fine.

My question is this:

Doing it this way, the JS library ends up in our git repository, because it gets copied into the /public folder. Is this recommended? We are hosting our site using Forge, which knows to run npm install on git update. So is there a way of not putting this library in our git repository? What is recommended?

Thanks.

0 likes
1 reply
jlrdw's avatar

You could just use the minimized version separate from mix all together.

Please or to participate in this conversation.