The JavaScript Chat SDK

Our JavaScript SDK allows you to easily add chat to your app. You can install the SDK 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>.

4;k=t.Promise;t.Talk={v:2,ready:{then:function(f){if(k)return new k(function(r,e){l.push([f,r,e])});l
5.push([f])},catch:function(){return k&&new k()},c:l}};})(window,document,[]);

Make sure you include it on every page of your app, so that TalkJS's notification features work correctly.

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:

1npm install talkjs --save
3# or, if you use yarn
4yarn add talkjs

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

1const Talk = require('talkjs');
3// or, if you use ES6 or TypeScript
4import 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):

Screenshot showing VSCode with Typescript's autocomplete with TalkJS

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.