Skip to main content

ES6 Babel Transforms : Code Injection and Increase in File Size

This post aims to give a rough idea on the increase of file size after applying babel transforms to ES6 JavaScript. These figures depend highly on your style of writing code since each extra space leads to an additional byte. However, the transform comparisons will give you an idea on how they are treated by babel and how much of additional code will be injected in your file. 

These file sizes are non-uglify, non-gzipped and without any method of compression on OSX.

let - var

  • 3 bytes for the first rename. 
  • 4 bytes for each subsequent rename.

const - var

  • Save 1 byte per declaration.

Class Tranforms

  • 852 bytes for using simple class declaration with a constructor. Adds two new functions, namely, _createClass and _classCallCheck.


  •  
  • 2114 bytes for creating and extending a class.



  • Extending a class adds two more functions let us have a look at them, namely,
    _get and _inherits.










Arrow => functions

  • 20 bytes per usage, depends on the usage as well.


Template Strings

  • A little less than 4 bytes per variable call.



Destructuring

  • Increase is equal to the size of key variables + 2 bytes each.


Default Arguments

  • 77 bytes per default argument.

Custom `arguments` Keyword

  • 117 bytes per function.

Comments

Popular posts from this blog

Two concepts to help upgrade our definition of science

Two concepts to help upgrade our definition of science.  Everybody agrees that there are a ton of things which people believe in to have some basis in science but don’t. This agreement is however limited to what somebody else believes in and not they themselves. Applying the scientific method to everything that we come across is not possible. We as individuals have neither the resources nor would our experience as a single data point count for anything more than an anecdote. There are two concepts to help us check if what we believe in would even qualify to be evaluated by the scientific method. The first is “correlation does not imply causation”. Just because two things are found to be correlated, it does not mean one is the cause of the other. The more popular version of it is a similar fallacy, an event that followed another was necessarily a consequence of the first event. For example, you bought a car on a Saturday and then later met with an accident. Drawing a conclusion th

Charting API for Financial Markets - JavaScript (SVG)

A brief about the released version of this API is available here . As a part of the last semester of my graduation program (Bachelor of Engineering in Information Technology), I have been interning with a start-up, namely uTrade Solutions .  uTrade™ Solutions is a financial trading technology company with various products including multi-asset trading platform, algorithms and analytics. Instead of walking through my experience of working in a start-up, I would directly move to a short discussion about my project.  uTrade Solutions is working to develop a financial analytics portal and every financial analytics portal employs the use of advanced charting. To draw and display different types of charts on the web, there are two main options which are widely used and acknowledged. Namely, Adobe Flash and Scalable Vector Graphics (SVG) .  Using Adobe Flash has two main disadvantages: It requires the installation of an additional plugin to run content on the browser. It is

The secret life of the OnePlus 3

So I bought the OnePlus 3 on launch day; it has been about a week since. Buying products on launch day is a practise I am personally against and don’t recommend, but end up falling for more often than not. More comprehensive reviews and bugs surface only after a few weeks from the public release; this time however, things were a little different. Reviews by both The Verge and MKBHD were released as soon as the launch event ended. For me, reviews by The Verge are nothing more than in-depth first impressions. It seems as if they don’t really use the phone as a daily driver or even for more than a day but instead they have some really talented people who produce great content and sometimes catch things that others don’t in the first go. MKBHD on the other hand has always been very reliable- he uses each phone as his daily driver for at least a week before publishing a review. The OnePlus3 got rave reviews by both and was marked to be nearly perfect. The interesting bit however is t