talk.js is our JavaScript SDK for adding chat to your app. You can install it into your site in two ways:

1. Copy & paste

Put the code below in your app's <head> or at the very end of the <body>.

<script>
(function(t,a,l,k,j,s){
s=a.createElement('script');s.async=1;s.src="https://cdn.talkjs.com/talk.js";a.head.appendChild(s)
;k=t.Promise;t.Talk={v:1,ready:{then:function(f){if(k)return new k(function(r,e){l.push([f,r,e])});l
.push([f])},catch:function(){return k&&new k()},c:l}};})(window,document,[]);
</script>

Make sure you include it on every page of your app, for TalkJS's notification features to work.

2. Use NPM

If you use a bundler for your client-side JavaScript, such as Webpack, Browserify or Parcel, you can use NPM to import TalkJS into your app:

$ npm install talkjs --save

# or, if you use yarn
$ yarn add talkjs

In your code, in place that is loaded on every page, do:

const Talk = require('talkjs');

// or, if you use ES6 or TypeScript
import Talk from "talkjs";

Our NPM package ships with TypeScript type definitions, which means you'll get auto-completion on certain editors (such as Visual Studio Code or Atom):

TalkJS is lightweight

We've done our best to keep the core TalkJS SDK exceptionally small, so that your page load times are not impacted. talk.js is only ~23kB gzipped and it is served from our global CDN to ensure fast load times across the globe.

Also, talk.js is loaded asynchronously, so that your page can display before talk.js has loaded.