Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve first paint speed, show splash screen quickly on load #2001

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/web-client/src/app.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand All @@ -20,6 +20,15 @@
data-sveltekit-preload-data="hover"
style="overflow: hidden; background-color: black"
class="h-screen">
<splash-screen
class="spacy-y-8 absolute z-[15] flex h-full w-full flex-col items-center justify-center space-y-10 bg-black">
<svg class="h-56 w-56">
<use xlink:href="/icons.sprite.svg#hot-or-not-logo"></use>
</svg>
<svg class="h-5 w-5 animate-spin-slow opacity-50">
<use xlink:href="/icons.sprite.svg#loading"></use>
</svg>
</splash-screen>
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
13 changes: 1 addition & 12 deletions packages/web-client/src/components/layout/SplashScreen.svelte
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
<script lang="ts">
import { fade } from 'svelte/transition'
import { hideSplashScreen, splashScreenPopup } from '$stores/popups'
import { hideSplashScreen } from '$stores/popups'
import { onMount } from 'svelte'
import Icon from '$components/icon/Icon.svelte'

onMount(() => {
hideSplashScreen(5000)
})
</script>

{#if $splashScreenPopup.show}
<splash-screen
out:fade|local={{ duration: 500 }}
class="spacy-y-8 absolute z-[15] flex h-full w-full flex-col items-center justify-center space-y-10 bg-black">
<Icon name="hot-or-not-logo" class="h-56 w-56" />
<Icon name="loading" class="h-5 w-5 animate-spin-slow opacity-50" />
</splash-screen>
{/if}
4 changes: 4 additions & 0 deletions packages/web-client/src/stores/popups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export function hideSplashScreen(timeoutMs: number = 2000) {
if (get(splashScreenPopup).shown) return
if (splashScreenTimeOut) clearTimeout(splashScreenTimeOut)
splashScreenTimeOut = setTimeout(() => {
const el = document.getElementsByTagName('splash-screen')
if (el && el[0]) {
el[0].remove()
}
splashScreenPopup.set({ show: false, shown: true })
}, timeoutMs)
}