Skip to content

Commit 0ab23df

Browse files
committed
[dashboard] Lazy-load Chargebee library before creating a client
1 parent 3896bd1 commit 0ab23df

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

components/dashboard/src/chargebee/chargebee-client.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ export class ChargebeeClientProvider {
1414

1515
static async get(gitpodServer: GitpodServer) {
1616
if (!this.client) {
17+
await new Promise<void>(resolve => {
18+
const scriptTag = document.createElement('script');
19+
scriptTag.src = 'https://js.chargebee.com/v2/chargebee.js';
20+
scriptTag.async = true;
21+
scriptTag.addEventListener('load', () => {
22+
resolve();
23+
}, { once: true });
24+
document.head.appendChild(scriptTag);
25+
});
1726
const site = await gitpodServer.getChargebeeSiteId();
1827
this.client = (((window as any).Chargebee) as chargebee.Client).init({
1928
site

0 commit comments

Comments
 (0)