Get started with the Client SDK

The Weavy Client SDK is a javascript library that you add to your existing app or website. The library can be added in different ways depending on your site configuration.

Client script configurator

To obtain a copy of the client SDK you should point your browser to https://{weavyurl}/client to get to the client configurator in your weavy installation. You will be presented with a form where you can configure the client SDK. As you can see the url to the client SDK can be modified to get different configurations of the SDK.

Some examples:

  • weavy.js - Standard configuration of the client SDK
  • weavy.bundle.js - Client SDK including jQuery
  • weavy.extended.js - Client SDK including additional plugins required for the drop-in ui, a.k.a "The Dock"
  • weavy.min.js - Minified standard configuration

Once you are happy with the configuration, you can reference the configured url directly or download and include the file in your app if necessary.

Plain HTML example

To include the client SDK in a javascript app or your own build environment, you have to load the SDK globally (if you use the standard configuration, jQuery is also required and must be loaded prior to weavy.js). When you have loaded the SDK, you can create a new Weavy() instance anywhere at any point in your app. To avoid timing issues when loading it may be a good idea to make sure you instantiate Weavy at the window DOMContentLoaded event.

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://{weavyurl}/javascript/weavy.js"></script>
<script>var weavy = new Weavy();</script>

Javascript loader example

The javascript loader is suitable for environments where Weavy is injected or if you want to load the script from javascript directly.

The configured javascript from the Client Configurator should look similar to the following example, the script.src property should of course point to your installation instead of {weavyurl}.

(function (window, document) {               	
  var onload = function() {
    var script = document.createElement("script"); 
    script.src = "https://{weavyurl}/javascript/weavy.js"; 
    script.onload = function(){
      var weavy = new Weavy();
    };
    var firstScript = document.getElementsByTagName("script")[0]; 
    firstScript.parentNode.insertBefore(script, firstScript); 
  };
  if(document.readyState !== "complete") {
      window.addEventListener("load", onload, false); 
  } else {
      onload();
  }
})(window, document);

You can place this snippet in anywhere in your code as it will load weavy.js globally before creating a new Weavy() instance.