Preact Vs React JS

  Рет қаралды 5,513

Stephen Blum

Stephen Blum

Күн бұрын

Пікірлер: 37
@robethrahmatullah7779
@robethrahmatullah7779 Жыл бұрын
5:19 You actually need "react-dom" (42 KB minified + gzipped) to render something in the browser 10 KB "react" library only contains the core runtime so it could be used for other platforms (react native, ink, etc.)
@StephenBlum
@StephenBlum Жыл бұрын
@robethrahmatullah7779 ah good catch! This is noteworthy in that case. Since react-dom a masive 42KB minified and gzipped. Preact is a much smaller library in comparison.
@vitezslavackermannferko7163
@vitezslavackermannferko7163 2 ай бұрын
Preact doesn't need an equivalent ofreact-dom library to function?
@shashankpandey8346
@shashankpandey8346 4 күн бұрын
I am currently using react in my company portfolio website and I think it is pretty slow and heavy for just rendering some shadcn components and framer-motion and static data. I have rarely used useState too, let alone other hooks like useeffects, reducer, memo and callbacks. But I don't think this is for me, since the syntax are basically different and I would be converting like entire code manually. Last time I checked, there were at least 20 components and 10 pages. not gonna transfer.
@StephenBlum
@StephenBlum 4 күн бұрын
Yes you are right. ReactJS is very slow. Preact can help speed it up. And if you use the preact-compat library, most components should work github.com/preactjs/preact/blob/main/compat/package.json
@damiangilz
@damiangilz 8 ай бұрын
What i find weird of Preact is that the docs still push class components hard.
@StephenBlum
@StephenBlum 8 ай бұрын
good point! Yes class components are push for compatibility focus. That may be due to docs that should be updated to push harder on "hooks". PreactJS supports hooks and this can be a better approach
@MichaelJiang-fj8kg
@MichaelJiang-fj8kg 2 ай бұрын
Signals is the real killer in Preact! I love signals
@StephenBlum
@StephenBlum 2 ай бұрын
Nice! Yes it's a huge win on performance and simplicity. It automatically notifies any dependents when that value changes. Faster and more efficient ❤️
@ramsey2155
@ramsey2155 9 ай бұрын
You need to use the deployment configuration for the actual optimization...
@StephenBlum
@StephenBlum 9 ай бұрын
Nice! that explains the optimization opportunity. Thank you! 😊
@lifeofcode
@lifeofcode Жыл бұрын
Good stuff as always bro. LOL! I believed preact at face value when they said they were 3kb. Never looked into it! I've heard people using the preact signals package though in react. Seems like it could be cool.
@StephenBlum
@StephenBlum Жыл бұрын
😄 It was funny to see that the two libraries were the same size! Both about 10kb minified. You are right, the signal package can help improve the performance. It seems like the largest advantage that Preact can offer
@dereksniper
@dereksniper Жыл бұрын
was looking into this and seems like a better alternative. However would you make a project in vite in react and just import signals or just go preact?
@lifeofcode
@lifeofcode Жыл бұрын
@@dereksniper vite + react with signals is how I've seen most taking advantage of it.
@StephenBlum
@StephenBlum Жыл бұрын
@@dereksniper excellent question. I would go with the simplest approach. Fewer dependencies. I tend towards liking things simple and performant 😄 using preact directly would be a great choice
@einfacherkerl3279
@einfacherkerl3279 11 ай бұрын
the real problem is that everyone is trying to fix react. Solidjs, qwik, Preact etc. they are trying to create solution for which problem needs to be invented. what is needed is the application framework that helps build app logic. this is not fully solved by redux, xstate , mobx etc.
@StephenBlum
@StephenBlum 11 ай бұрын
good point yes that React itself is already provides the most common needs for the majority of apps. today React does have a few missing or unoptimized capabilities. Things like redux, xstate, mobx can be standardized directly in React core itself as optional recommended additions. We could benefit from the performance boosts that Preact promises if React would make the needed adjustments to provide a faster user experience
@nexovec
@nexovec 7 ай бұрын
I don't like this, not only because you don't understand react-dom, which means you have never used react as an actual js library in the browser, else you'd know you can't even render anything this way, but more importantly, because the way react makes you program results in larger bundles than strictly necessary. How is it possible you feel confident talking about this? Waste of time.
@StephenBlum
@StephenBlum 7 ай бұрын
You are right 😄 The miss in the video, it is exactly as you describe. React + React-dom is massive compared to Preact. This is a big aspect to choosing Preact and improving your user's experience by providing a faster and smaller web framework library.
@nexovec
@nexovec 7 ай бұрын
@@StephenBlum That was already pointed out by others too. What I want to know is if it's possible to ship a client-side SPA under say 500kb using something that can leverage the existing React components ecosystem. Preferably without multiple build steps too. Can't get an answer anywhere on the internet. Maybe no-one has tried... maybe react devs don't care about bundle size and performance until they receive complaints from customers, and then what they do is offload something to SSR and call it a day.
@StephenBlum
@StephenBlum 7 ай бұрын
@@nexovec looking around there does appear to be a way to reduce SPA JS size using React + Ecosystem. If I can get it to work I'll add this to the planned upcoming videos as a tutorial walkthrough! 🙌
@StephenBlum
@StephenBlum 7 ай бұрын
@@nexovec this actually looks like a pretty good option for existing-projects: preactjs.com/guide/v10/getting-started#integrating-into-an-existing-pipeline it requires editing your build files with Babel and Webpack. If you are not using those, then it is a necessary step to get as much as possible from PreactJS. The aliasing is need to replace react core and react-dom. Also Preact +10 includes hooks. Which is a problem I ran into when getting it to eventually work.
@nexovec
@nexovec 7 ай бұрын
​@@StephenBlum Do show some benchmarks and comparisons of a react app ported into preact, if you go that far, in which case count me interested 🙌
@LazyDesigner65
@LazyDesigner65 4 ай бұрын
😮
@StephenBlum
@StephenBlum 4 ай бұрын
😄🙌
@WisamJbori
@WisamJbori 2 ай бұрын
disk size is not file size, I hate that I wasted 2 minutes of my life
@StephenBlum
@StephenBlum 2 ай бұрын
actually that's an interesting point. wait, disk size of a file is not the same as the file size? Yes! this is true. Because disks are segmented into chunks ( block size ). Usually 4K chunks. So if you have an 5K file it actually takes up 8K on disk.
@KhaiyomOdinaev
@KhaiyomOdinaev 21 күн бұрын
It's obvious you have no idea what you're talking about. The video doesn't show disk size-it’s the file size in his terminal. Also he was using curl, and during the download, it clearly showed 11107 bytes received. Maybe pay attention next time.
@StephenBlum
@StephenBlum 20 күн бұрын
@@KhaiyomOdinaev yes you are right it was 11K for both. I missed an important aspect. react-dom is required for web apps and adds another 50K. preact doesn't require this extra size. this is where the strength of preact starts to show up. not only is it 5x smaller in javascript, it has a few improvements to dom interaction updates and repaints using signals/events. Preact is better than I gave credit for in the video.
@KhaiyomOdinaev
@KhaiyomOdinaev 20 күн бұрын
@@StephenBlum Hi! Just to clarify, my earlier reply wasn’t directed at you-it was more of a response to the hater’s comment. Your video was actually really helpful during my research when I was considering Preact for Astro. While I’ve ultimately settled on Solid.js after more research, your content was a great resource along the way. Thanks for sharing your insights!
@StephenBlum
@StephenBlum 20 күн бұрын
@@KhaiyomOdinaev thank you for mentioning this 😄 Your clarification is helpful. Happy you were able to get data from my video. Solid.JS is a great framework! Clean and easy to understand coming from React
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 494 М.
Single Line React Performance Boost with Million
5:52
Jack Herrington
Рет қаралды 34 М.
小丑教训坏蛋 #小丑 #天使 #shorts
00:49
好人小丑
Рет қаралды 54 МЛН
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
؟ Docker ليه بنستخدم 💙
18:52
Yehia Tech يحيى تك
Рет қаралды 146 М.
Rethinking The Linter
19:26
Theo - t3․gg
Рет қаралды 78 М.
React VS Svelte...10 Examples
8:35
Beyond Fireship
Рет қаралды 596 М.
Don't Use React Context!! Use This instead
13:34
CoderOne
Рет қаралды 29 М.
Actix Web vs. Axum: Is One a Clear Winner?
8:59
OptiCode
Рет қаралды 2,9 М.
State Managers Are Making Your Code Worse In React
13:33
Web Dev Simplified
Рет қаралды 211 М.
Signals In React Will BLOW Your Mind 🤯
7:30
Mehul - Codedamn
Рет қаралды 68 М.
React Query Is (Still) Essential - My Favorite React Library
11:04
Theo - t3․gg
Рет қаралды 160 М.
What is Preact? (the best small React alternative)
12:04
Harry Wolff
Рет қаралды 28 М.
The Story of React Query
8:55
ui․dev
Рет қаралды 116 М.