You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working on a recent project I was looking at the compiled javascript code and noticed "prototype" was written dozens of times, once for each public method. The library I was working on is 13Kb in size minified, and removing all the "prototypes" reduced the size to 12.5Kb, that's half a kilobyte!
Compiled JavaScript files could considerably smaller if we applied all methods to the prototype as an object, instead of one at time.
The performance of the code should be identical and larger libs see a huge size improvement for free. For example, the BabylonJS core lib could be almost 20Kb smaller.
The text was updated successfully, but these errors were encountered:
TypeScript Version: 2.1.4
While working on a recent project I was looking at the compiled javascript code and noticed "prototype" was written dozens of times, once for each public method. The library I was working on is 13Kb in size minified, and removing all the "prototypes" reduced the size to 12.5Kb, that's half a kilobyte!
Compiled JavaScript files could considerably smaller if we applied all methods to the prototype as an object, instead of one at time.
Let's take a simple class
Existing Behavior
Once we compile with tsc, we get this:
Notice that we get the "prototype" syntax twice, once for each method.
New Suggested Behavior
Instead, the compiler could combine the multiple methods into a JS object applied to the prototype, saving a good deal of space:
The performance of the code should be identical and larger libs see a huge size improvement for free. For example, the BabylonJS core lib could be almost 20Kb smaller.
The text was updated successfully, but these errors were encountered: