Re:YouTube Video as Background in React
by zfxfr on Sunday March 27, 2022 @05:49AM
(#30819025)
Do we really need react for this ? Also it looks like there are thousands of LOC for just this
[ Parent
| on HN ]
Re:YouTube Video as Background in React
by pcthrowaway on Sunday March 27, 2022 @07:10AM
(#30819359)
You certainly don't need react to embed a youtube video in a background.. this library provides a react component that does this, which is useful to react users who want this effect.
The amount of code used here to do something so simple is absolutely staggering. This library abstracts over youtube-react, which abstracts over youtube-player, which abstracts over the Youtube API itself, each one proving hundreds or thousands of LoC.
This is a serious dependency sandwich. If you want to put a single Youtube video in the background of a div then you don't need thousands of lines of code for managing player controls and state changes. You could probably take 1/10th of that code in youtube-react (the bit that integrates a react component with a 3rd party lib that wants control over the DOM, common pattern with React) and get the same result.
Re:YouTube Video as Background in React
by dismantlethesun on Sunday March 27, 2022 @08:20PM
(#30825579)
What you are saying is a worthy fault for a front end library, but it’s kind of funny that no one thinks this way when it’s the backend.
To do a simple k-means clustering on a textual corpus, someone might pull in all of scipy and ntlk which is tens of thousands of lines of code.
I think programmers don’t generally consider dependency size unless it’s on the order of multiple gigabytes.
Re:YouTube Video as Background in React
by pcthrowaway on Sunday March 27, 2022 @09:08PM
(#30825911)
I suspect a lot more LoC are fetched when you visit youtube anyway, even if it is edge-optimized