muxinc / elements

Custom elements for working with media in the browser that Just Work™
https://elements-demo-nextjs.vercel.app
MIT License
266 stars 49 forks source link

Feature Request: Reduce bundle size, currently arround 120kB #741

Open JoeMatkin opened 1 year ago

JoeMatkin commented 1 year ago

Is there an existing issue for this?

Which Mux Elements/Packages does this apply to? Select all that apply

mux-video-react

Description

There is no easy way to lazy load the player and even so they bundle size is way to big.

It added 120kB to my first load JS

Instead I'm now lazy loading react-player with a reduced bundle size of 120kB

Expected Behavior

A reduced bundle size and the ability to defer / lazy load

dylanjha commented 1 year ago

@JoeMatkin thanks for opening. Lazy loading will depend on your framework and build setup, what are you using?

We do have a guide here about Lazy Loading Mux Player

The biggest dependency we have is Hls.js, which is beefy and required in order to make Hls playback work in all non-Safari browsers.

Hahlh commented 8 months ago

@JoeMatkin thanks for opening. Lazy loading will depend on your framework and build setup, what are you using?

We do have a guide here about Lazy Loading Mux Player

The biggest dependency we have is Hls.js, which is beefy and required in order to make Hls playback work in all non-Safari browsers.

HLS leads to 383kb being loaded client side in our case.

Not including the other 83kb by mux-embed and another 135kb by @mux. That's quite a bit.

image

Is that expected? Our only dependency in package.json is "@mux/mux-player-react": "^1.14.2",.

Might v2 contain some improvements in that regard? Or is this unexpected we should hunt for some kind of misconfiguration?