Bootstrapping JavaScript API

This post was authored by Ina Uzunova, Product Owner of vSphere Client SDK

This blog post gives a brief overview of a new mechanism for JavaScript API bootstrapping introduced in vSphere 6.5 Update 1 and explains why you should take advantage of it.

In previous releases, the JavaScript APIs have been initialized through a custom file web-platform.js that must be included in your HTML plugin resources. Packaging the web-platform.js file in your plugin has two main disadvantages:

  • It uses a single shared global object for all plugins. As a result, other plugins that have an older version of that file, and are installed on the same vSphere environment where your plugin is installed, may override the same shared global object. This may impact your plugin’s functionality.
  • The file becomes part of your plugin package delivery. If you want to consume the latest bug fixes and improvements to JavaScript APIs provided in the next release, you need to update your copy of the web-platform.js to include these changes and release a new plugin version to your users.

The new JavaScript API bootstrapping mechanism is supported on vSphere 6.5 U1 and future releases. It is not supported on any previous vSphere release.

The mechanism is simple, yet powerful and easy to use. Instead of including the web-platform.js in your plugin package, you can access the same set of JS APIs by a single call:

this.webPlatform = window.parent.vSphereClientSDK.getWebPlatformApi(window);

For each call getWebPlatformApi(window) returns a unique JavaScript object, and you can access all existing JavaScript APIs through this object. For example, to close a dialog box using the new interface object:


The advantages of this new bootstrapping mechanism are:

  • You no longer share a global object with other plugins and they cannot impact your plugin’s functionality.
  • Since you no longer need to include the web-platform.js file in your plugin package, any bug fixes and improvements to existing JavaScript APIs introduced in the next release, will be available transparently through the JavaScript interface object which you instantiated in your code. The fixes and improvements will be available at the moment the user upgrades to the vSphere release where they are introduced.

For more details please refer to the official documentation and the HTML Client SDK samples available from the \html-client-sdk\samples directory.


Leave a Reply

Your email address will not be published.