How to load from node_modules
vs. script tag #582
Description
Hey folks, is it possible to load this as a module, from node_modules
, and if so, how? I can't find any documentation for doing so either in this repo or on your website, there's just directions for loading it using a script tag.
My use case is within a Chrome extension, where I must package all scripts with the extension and I can't append script tags to the page without polluting the page.
It looks like it should be possible to load this as a module given that it is packaged as UMD and published to npm, but I don't know how to initialize the module i.e. what is the replacement for analytics.load("YOUR_WRITE_KEY"); analytics.page();
? When I try doing
const analytics = require('analytics.js');
analytics.load("MY_WRITE_KEY");
I get an error about load
not being defined.
I know that my bundler is properly configured to load from node_modules
so that is not the problem.
I would also like to verify the following:
- If I load this as a module vs. a script tag, will it attempt to append any other script tags to the page? Hopefully no.
- If I load this as a module, do I need to custom-build that module to include only the integrations I use and if so how? Distributed JS is bloated for no reason #519 and linked issues make me suspicious.