Skip to content

What is the “proper”/best-practice way to add additional JavaScript libraries to a Magento project?

I have seen a couple different methods. I’m wondering if there is a best practice?

I know Magento stores JavaScript libraries in /lib, and I know how to include those in a module using RequireJS.

In a couple places, I have just copy/pasted JavaScript library files into a module-specific folder…it doesn’t feel right, but it works.

My question is: If I wanted to include a library like React (which would be used by ALL modules) – how would I do that?

Copy paste into /lib? NPM install…?