Skip to content

Commit 3670da7

Browse files
Merge pull request #2587 from appwrite/feat-profile-preload-cdn-assets
2 parents 1395495 + 08d0e62 commit 3670da7

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/lib/studio/studio-widget.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ const STYLE_ATTRIBUTE = 'data-appwrite-studio-style';
1111
const BLOCK_START_BASE_OFFSET = 48;
1212
const INLINE_START_BASE_OFFSET = 8;
1313
const CACHE_BUSTER = new Date().getTime();
14-
const CDN_URL =
14+
export const CDN_URL =
1515
'https://esm.sh/@imagine.dev/web-components@0/web-components?bundle=false&deps=react@19.1.0,react-dom@19.1.0&cache=' +
1616
CACHE_BUSTER;
17+
export const CDN_CSS_URL =
18+
'https://esm.sh/@imagine.dev/web-components@0/imagine-web-components.css?cache=' + CACHE_BUSTER;
1719
const DEV_OVERRIDE_WEB_COMPONENTS = env?.PUBLIC_AI_OVERRIDE_WEB_COMPONENTS === 'true';
1820

1921
let component: HTMLElement | null = null;

src/routes/+layout.svelte

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import { isSmallViewport, updateViewport } from '$lib/stores/viewport';
2626
import { feedback } from '$lib/stores/feedback';
2727
import { ProfileMode, resolvedProfile } from '$lib/profiles/index.svelte';
28+
import { CDN_CSS_URL, CDN_URL } from '$lib/studio/studio-widget';
2829
2930
function resolveTheme(theme: AppStore['themeInUse']) {
3031
switch (theme) {
@@ -185,6 +186,11 @@
185186
{/if}
186187

187188
<link rel="stylesheet" href={`${base}/css/profiles/${resolvedProfile.id}.css`} />
189+
190+
{#if resolvedProfile.id === ProfileMode.STUDIO}
191+
<link rel="preload" as="style" type="text/css" href={CDN_CSS_URL} />
192+
<link rel="preload" as="script" type="text/javascript" href={CDN_URL} />
193+
{/if}
188194
</svelte:head>
189195

190196
<Root theme={resolveTheme($app.themeInUse)}>

0 commit comments

Comments
 (0)