Best Practices & Module Loading Tutorial

This tutorial refers to Userlike’s live chat product. For Userlike’s Unified Messaging tutorials, click here.

Widget Loading with RequireJS

You can load our Chat Widget Loader code with RequireJS, too. It's totally simple and you are able to pass additional options to configure the Widget setup.

The options can be passed as an object to the "load" method. Available options are:

If you use an AMD loader, calling the "load" method is necessary to initialize the Chat Widget.
Option Description
avoid_globals: false(default)|true You can prevent the API methods from being bound to the window object.
ready: function You can pass your own on-ready callback function.
remoteReady: function You can pass your own on-remote-ready callback function.
custom_data: object If you want to initialize your Widget with custom data you can pass your object to the custom_data option.
The Chat Widget is using a single global object to handle JSONP callbacks. So please do not overwrite the userlike-object in the global scope!

After loading the Chat Widget with a module loader you are still able to reference the Widget in the global scope by calling the "window.userlike" object.