How to import third party js not available via npm

I’m using Ionic 3 and I have a third party js file which I need to use and it isn’t available via npm. How can I import it?

I’ve tried adding the js script tag to index.html, but that doesn’t expose the library within the .ts file.

It normally does. Loading something in index.html executes whatever code it includes, which then can be used in your normal app code. You just have to know the variable it creates and declare that in your code so TS doesn’t think it doesn’t exist.

1 Like