-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Feature request: lazy players #738
Comments
Hey @trurl-master, yeah this has been on my radar for a long time. It would reduce the bundle size massively and essentially render the single player imports redundant. I can look at implementing this, but don't have an exact timeline. |
I've pushed my first attempt at this as an alpha version of
|
Hi, @cookpete could you please let know what braking changes are in 2.0 version? I've successfully added the alpha version to my project and haven't spotted any breaking changes or problems yet. |
@ramlez Namely the single player functionality eg import YouTubePlayer from 'react-player/lib/players/YouTube' becomes pretty much redundant, as only the Youtube player will be loaded if you only ever use a Youtube URL. I should be able to get a bit closer to releasing this in the next couple of days. |
I'm also considering removing the |
Hey @cookpete @trurl-master, until |
@dbismut Is there much benefit to including the lazy player code in SSR? Most of the time the only thing rendered is a single |
@cookpete it's not so much that SSR actually makes sense in this case, but rather than using ... which redirects to this page: https://reactjs.org/docs/error-decoder.html/?invariant=294 Let me know if you prefer that I open a separate issue for this, as someone will open it sooner or later. |
^ i also had the above issue, wondering what to do about it... |
Is there a quick fix for Suspense to just not render anything during SSR, rather than breaking things? This seems like a stupid problem to have when ReactPlayer doesn’t really benefit from rendering anything on the server. |
Well, I guess you could detect if you're server-side: const isBrowser = (typeof window !== 'undefined' && window.document)
return <div>{ isBrowser && <Suspense /> }</div> |
It's also breaking my Gatsby build with the same exact error posted by @dbismut. Wondering exactly how to get around this? |
@ericnation I downgraded to 1.15.3...that fixed the build and got me past this issue, but I don't really need any of these lazy/suspense features, so YMMV. |
@ericnation I guess you can use the method mentioned by @dbismut to get rid of the build-time problem.
Just wonder if |
That’s the idea indeed! |
This should be fixed in |
Can you add this to the docs? Im trying to figure out how to improve load time. |
Note that from I'm not considering it a breaking change as things won't actually break – the only impact will be a slightly bigger bundle size until you start importing from I've added clarification to the readme to only use it if your build pipeline supports dynamic |
Fixes cookpete/react-player#912 Fixes cookpete/react-player#907 Fixes cookpete/react-player#865 Sort of fixes cookpete/react-player#910 Sort of fixes cookpete/react-player#902 Affects cookpete/react-player#886 Affects cookpete/react-player#738
Fixes cookpete/react-player#912 Fixes cookpete/react-player#907 Fixes cookpete/react-player#865 Sort of fixes cookpete/react-player#910 Sort of fixes cookpete/react-player#902 Affects cookpete/react-player#886 Affects cookpete/react-player#738
I'm getting this error too on build - I'm on version 2.11.2. Any ideas? |
@alex-major-digital Are you importing It’s been over three years now since I added the |
Hi @cookpete, thanks for the quick reply! I get the error when importing both |
Fixes cookpete/react-player#912 Fixes cookpete/react-player#907 Fixes cookpete/react-player#865 Sort of fixes cookpete/react-player#910 Sort of fixes cookpete/react-player#902 Affects cookpete/react-player#886 Affects cookpete/react-player#738
Motivation: On my page I don't know what player will be used in each particular case and many of the players will never be used, so I would like to lazily load only one player in each particular case.
Something like this:
The problem here is that the
canPlay
logic is inside of each individual player file and to know whether a player is capable of playing the url I need to download it. Could thecanPlay
logic be extracted from each individual player to a separate file?The text was updated successfully, but these errors were encountered: