Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Just built our first major react/redux site. Moderate complexity, I'd say. React runs pretty fast, but on page load we take 2.5s to compile all the JavaScript.


Are you sure compilation is the bottleneck? 2.5s seems way too much by an order of magnitude.

Have you looked into compiling during your build step instead of at runtime?


In a large application my rule of thumb is 1/3 compile, 1/3 React internals (which includes DOM updates) and 1/3 product code. 2.5 seconds is a lot, but not surprising if an application is being shipped as a multi-megabyte bundle.

Compiling as a build step doesn't get you very far when you are forced to ship source code to JS engines.


I guess I may be a bit confused on what he meant by compilation

Since JS is JIT compiled, I assumed perhaps he was delivering his scripts in raw JSX+ES6 and transpiling at runtime via babel's browser.js (as shown by react's Getting Started guide) [1].

If he meant time spent parsing the JS then I'd be a bit suspicious about the 2.5s both because of the extraordinary length and also I find it hard to believe someone who would know how to measure parse time would mistake the term with compilation.

[1]: https://facebook.github.io/react/docs/getting-started.html




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: