️(frontend) code split livekit-client from the main chunk

livekit-client is a 400ko package that was wrongly bundled in the main
index.js chunk.

Every page was loading this enormeous vendor package only necessary
to join and participate to a room.

It made sense to set the LiveKit log level at app init, however the
performance tradeoff forces us to move it as close as possible to
where it is actually needed.
This commit is contained in:
lebaudantoine
2026-05-26 10:11:08 +02:00
committed by aleb_the_flash
parent 426e6258a8
commit 995e6fa41d
3 changed files with 11 additions and 20 deletions
@@ -1,4 +1,3 @@
import { silenceLiveKitLogs } from '@/utils/livekit'
import { useConfig } from '@/api/useConfig' import { useConfig } from '@/api/useConfig'
import { useAnalytics } from '@/features/analytics/hooks/useAnalytics' import { useAnalytics } from '@/features/analytics/hooks/useAnalytics'
import { useSupport } from '@/features/support/hooks/useSupport' import { useSupport } from '@/features/support/hooks/useSupport'
@@ -9,12 +8,7 @@ export const AppInitialization = () => {
const { data } = useConfig() const { data } = useConfig()
useSyncUserPreferencesWithBackend() useSyncUserPreferencesWithBackend()
const { const { analytics = {}, support = {}, custom_css_url = '' } = data ?? {}
analytics = {},
support = {},
silence_livekit_debug_logs = false,
custom_css_url = '',
} = data ?? {}
useAnalytics(analytics) useAnalytics(analytics)
useSupport(support) useSupport(support)
@@ -29,7 +23,5 @@ export const AppInitialization = () => {
} }
}, [custom_css_url]) }, [custom_css_url])
silenceLiveKitLogs(silence_livekit_debug_logs)
return null return null
} }
@@ -12,6 +12,8 @@ import {
isRoomValid, isRoomValid,
normalizeRoomId, normalizeRoomId,
} from '@/features/rooms/utils/isRoomValid' } from '@/features/rooms/utils/isRoomValid'
import { useConfig } from '@/api/useConfig.ts'
import { LogLevel, setLogLevel } from 'livekit-client'
const BaseRoom = ({ children }: { children: ReactNode }) => { const BaseRoom = ({ children }: { children: ReactNode }) => {
return ( return (
@@ -32,6 +34,13 @@ const Room = () => {
const mode = isLoggedIn && history.state?.create ? 'create' : 'join' const mode = isLoggedIn && history.state?.create ? 'create' : 'join'
const skipJoinScreen = isLoggedIn && mode === 'create' const skipJoinScreen = isLoggedIn && mode === 'create'
const { data } = useConfig()
useEffect(() => {
const shouldSilenceLogs = data?.silence_livekit_debug_logs || false
setLogLevel(shouldSilenceLogs ? LogLevel.silent : LogLevel.debug)
}, [data?.silence_livekit_debug_logs])
useKeyboardShortcuts() useKeyboardShortcuts()
const clearRouterState = () => { const clearRouterState = () => {
+1 -11
View File
@@ -1,14 +1,4 @@
import { import { getBrowser, LocalParticipant, type Participant } from 'livekit-client'
getBrowser,
LocalParticipant,
LogLevel,
type Participant,
setLogLevel,
} from 'livekit-client'
export const silenceLiveKitLogs = (shouldSilenceLogs: boolean) => {
setLogLevel(shouldSilenceLogs ? LogLevel.silent : LogLevel.debug)
}
export function isFireFox(): boolean { export function isFireFox(): boolean {
return getBrowser()?.name === 'Firefox' return getBrowser()?.name === 'Firefox'