Skip to content

Reduce sidecar.v1.js size

In the current word of 1MB+ web apps, you can think that I am crazy, but I (as an author of 139 bytes library and Size Limit) think that 17 KB is too big for sidecar.v1.js 😄.

I am currently having 10 KB website and adding 17 KB of Sidecar is painful for me (but Gitter so nice, Sidecar UX is great and I love this project so much).

I investigated sidecar.v1.js and found a few simple steps to reduce the size. I think we can reach 10 KB.

  1. Removing object-assign polyfill. Any way it is used only in few simple places.

  2. Removing Array.from polyfill, because it takes a lot of checks in error messages like:

    if(null===t||"undefined"==typeof t)throw new TypeError("`Array.from` requires an array-like object, not `null` or `undefined`");var i,a,u=n.ToObject(t);if("undefined"!=typeof arguments[1]){if(i=arguments[1],!n.IsCallable(i))throw new TypeError("When provided, the second argument to `Array.from` must be a function");
  3. Use Rollup to trim webpack’s boilerplate and Object.defineProperty(e,"__esModule",{value:!0}) calls.

  4. Remove Node.js process polyfill (it could accidetly be added by wrong usage of process.env).

What do you think of these steps? I can try to find more steps to reduce size and send pull requests.

Edited by Andrey Sitnik