Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
austinpray-mixpanel authored Aug 1, 2024
1 parent f9829cf commit 7b52ea5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,30 @@ To load the core SDK and optionally load session recording bundle asynchronously
import mixpanel from 'mixpanel-browser/src/loaders/loader-module-with-async-recorder';
```

## Use as a browser JavaScript module

If you are leveraging [browser JavaScript modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules), you can use [`importmap`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap) to pull in this library.

```html
<script type="importmap">
{
"imports: {
"mixpanel-browser": "https://cdn.mxpnl.com/libs/mixpanel-js/dist/mixpanel.module.js"
}
}
</script>
<script type="module" src="main.js"></script>
```

Then you are free to import `mixpanel-browser` in your javascript modules.

```js
// main.js
import mixpanel from 'mixpanel-browser';

mixpanel.init('YOUR_TOKEN', {debug: true, track_pageview: true, persistence: 'localStorage'});
```

## Building bundles for release
- Install development dependencies: `npm install`
- Build: `npm run build-dist`
Expand Down

0 comments on commit 7b52ea5

Please sign in to comment.