React: Optimized build

Created on 28 Nov 2016  Â·  7Comments  Â·  Source: facebook/react

We target newer browsers only, Chrome, Firefox, MS Edge, without supporting Internet Explorer.

Is there or can there be a build that optimizes output for this scenario by excluding code that deals with Internet Explorer quirks? Also, is it possible to have ES 6 output to minimize the size of the output?

Most helpful comment

@yaycmyk I did an experiment with that. You get a bit of savings, sure, but nothing crazy. Also you have to be aware of all 3rd party deps you have that may use createClass.

A @reactjs build without React.createClass has a savings of (raw, gzip)
-26143 -6201 build/react.js
-3526 -1017 build/react.min.js
– https://twitter.com/iamdustan/status/783701952483856384

All 7 comments

It might be good to look into Preact.

Also, is it possible to have ES 6 output to minimize the size of the output?

I don't expect there to be substantial size changes from it. React source doesn't use ES6 heavily. You could try building React from source and disable some Babel transforms to check.

Is there or can there be a build that optimizes output for this scenario by excluding code that deals with Internet Explorer quirks?

There is no such build. I don't think we have more than a few small blocks of code dealing specifically with Internet Explorer, so it doesn't seem worth it in terms of complexity.

Or a ES6-targeted build without all the createClass stuff could be useful.

@yaycmyk I did an experiment with that. You get a bit of savings, sure, but nothing crazy. Also you have to be aware of all 3rd party deps you have that may use createClass.

A @reactjs build without React.createClass has a savings of (raw, gzip)
-26143 -6201 build/react.js
-3526 -1017 build/react.min.js
– https://twitter.com/iamdustan/status/783701952483856384

Very little code, aside from the ChangeEventPlugin, relates to IE anymore. A while back I gutted a bunch of IE8 legacy code:

Beyond that, the 16.0 release of React removes createClass, PropTypes, and many other parts of the API. The overall size is much smaller. @trueadm has also done some great work to bundle together React smarter to reduce the build size even more.

So lots of progress! I'm not sure what the next step is for this issue beyond the work progress made in the last 6 months. I'm going to close this out.

The overall size is much smaller.

I wouldn’t claim that yet because we also added some new features which tipped it back close to the old size. But we did remove some code to add room for new features.

Ack. Thanks for keeping me honest!

Was this page helpful?
0 / 5 - 0 ratings