Custom Web Client Library Generator

Now serving version

This generator can be used to create a Lightstreamer JavaScript library that only includes the classes you use in your application.

To use it:

  1. Select the classes you need from the first column. Note that some classes are not compatible with some environments (the legend on the bottom will help you select the correct classes). Currently, all the available classes are compatible with the Browser environment.

  2. Select the style of the library you want to generate.

    You have four options:

    • Use globals: Once the generated file is included on a page, a global reference to each included class is created on the window object. This is the easiest way to use the library, but as a drawback, it is also the easiest way to get a name collision in your application. If you go down this way, ensure that no other code/library on your page declares a global having the same name as one of the included Lightstreamer classes. NOTE: This option can only be used inside a browser page.
    • Use namespaced globals: The difference between this and the previous case is that one single global named Lightstreamer is created and a reference to each class is then attached to it (like Lightstreamer.Class). This version is much safer than the previous one as only one name is reserved by the Lightstreamer library, so that name collision will unlikely happen. NOTE: This option can only be used inside a browser page
    • Use AMD: In this case, no globals are created and Lightstreamer classes must be accessed using proper calls to the AMD require method. Unfortunately, this approach will pollute the page with a number of define calls using three or four letter module names (all of the names using a common "ls" prefix). This is completely safe only if Lightstreamer is the only library using the AMD mechanism on the page. If you are including other libraries that use AMD, or your own code uses AMD to define its own modules, you may need to choose the next option.
    • Use AMD with namespaced names: This is the preferred way to use the Lightstreamer Web Client Library. Each class will be defined as Lightstreamer/ClassName so that the risk of having two define mapped to the same name is close to zero.

    In all the cases, the Lightstreamer global is reserved and will be created on the page by the Lightstreamer library (including AMD cases).

    Note that the example on the right will always reflect an example based on the selected options (but not the selected classes).

  3. Choose whether to include the Promise polyfill or not:

    the library internally uses the Promise class; if the polyfill is not included either supply one to the page/application yourself, or use the library on a browsers/environment having such class readily available.

  4. In case you have chosen one of the AMD versions, you can optionally include a fake AMD loader; the fake AMD loader will expose the define and require methods but with limited capabilities:

    • this AMD implementation cannot download files from a server so that all of your classes already have to be included on the page through <script> tags
    • it only supports three-parameters define calls
    • the require method can only be called if all the define calls for the needed classes have already been executed
    • can only be used inside a browser page
    • does not handle most errors that could occur due to erroneous calls

    If you need a full fledged AMD loader, we suggest you to check out RequireJS.

Still having doubts? You can visit our forums to clear them out.