DEV Community

Discussion on: Why is React so Popular?

Collapse
 
quii profile image
Chris James

In SPA's, there is only one page, i.e, index.html. When you want to go to another page, the server provides the same page but with a different component injected into it. So, this makes the application way much more faster.

Well...

"It’s perceivably faster to load 8.5 megabytes of HTML than it is to load a single tweet with a client-side React app."

twitter.com/samuelhauser/status/12...

Collapse
 
nrabhiram profile image
Abhiram Reddy • Edited

Wow that's really interesting. I didn't know that. My experience with React has been great so far and I really did feel that it was faster. Guess I need to delve deeper into this.

Collapse
 
quii profile image
Chris James

The assumption that sending a small amount of data first and then loading it on the client is great for optimising time to first byte. The problem is that's not the only metric you need to worry about.

a) You typically will need to download more JS, this can cost a lot
b) Once the JS is downloaded your client needs to interpret and execute it. That can be extremely costly depending on the device.

Thread Thread
 
nrabhiram profile image
Abhiram Reddy

Oh I see. So are there better alternatives?

Thread Thread
 
quii profile image
Chris James

Honestly it depends, there's nuance. There's nothing "wrong" with using react and SPAs and there's nothing wrong with just generating a HTML string server side and returning that. It depends entirely on your use cases and systems.

I would say a lot of people are writing SPAs (with all the complexity it brings) and they probably don't need to.

I guess my overall point is you can't make blanket statements like your article says like "react is fast".

Thread Thread
 
nrabhiram profile image
Abhiram Reddy • Edited

Oh okay I totally get you. Thanks for the clarification. I was misinformed about this. I'll edit the post a little. Cheers!