Loaded

The client script can take a few seconds to load due to first, loading scripts, than setting the transport, and last registering the service worker.

You can use chemical.loaded to check if Chemical has loaded or wait until they have loaded.

window.addEventListener("chemicalLoaded", function(e) {
    console.log("Chemical is loaded: ", chemical.loaded)
});