DEV Community

Discussion on: Why to use React if HTML/CSS/JS works fine?

Collapse
pengeszikra profile image
Peter Vivo

I have only to choice: Vanilla JS + CSS - that for really size dependent small app for example : banner where you can optimize much as possible. jQuery total forget - really don't used long time ago. Every other case - the React is really small and fine choice: that means a single JSX file plus standard index.html like:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>- - -</title>
</head>
<body>
  <div id="base"></div>
  <script src="./index.js"></script>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

plus complicated jsx

import { render } from 'react-dom';

render(<pre>react-base-hello-message</pre>, document.getElementById("base"));
Enter fullscreen mode Exit fullscreen mode

May you found really slim react base working setup

With nice parcel boundler setup which is also good for Vannilla JS if remove react and react-doom from packagejson

Collapse
mukuljainx profile image
Mukul Jain

No matter how small React is, it will still bring something do the table and it's about 41kb gzipped (react + react-dom) thats a lot, so a plain JS is better for small work like you mentioned btw also checkout preact (never personally used) it's way smaller with and sufficient for a lot of use cases.

Thread Thread
pengeszikra profile image
Peter Vivo

Yes preact is smaller react, and I work with them around 3 years, and its fine! But in my use case : complex scientic desktop application that few kb. isn't count, however larger React compatibile libraries still important.