accurat / accurapp

Create JS apps with flexible build configuration, tailored for the specific needs of Accurat
MIT License
21 stars 5 forks source link

json-perf-loader, for improved JSON parsing #74

Open caesarsol opened 3 years ago

caesarsol commented 3 years ago

Suggestion: use json-perf-loader instead of the default webpack JSON loader.

Because the JSON grammar is much simpler than JavaScript’s grammar, JSON can be parsed more efficiently than JavaScript. This knowledge can be applied to improve start-up performance for web apps that ship large JSON-like configuration object literals (such as inline Redux stores). Instead of inlining the data as a JavaScript object literal.

As long as the JSON string is only evaluated once, the JSON.parse approach is much faster compared to the JavaScript object literal

I've asked if that is still useful for webpack v4 here, just to be sure it makes sense :)