Skip to content

A Babel plugin which eliminates closures from your JavaScript wherever possible.

License

Notifications You must be signed in to change notification settings

codemix/babel-plugin-closure-elimination

Folders and files

NameName
Last commit message
Last commit date
Oct 7, 2017
Sep 24, 2017
Jan 11, 2016
Oct 11, 2017
Oct 11, 2017
Sep 21, 2017
May 13, 2015
Jan 26, 2016
Dec 12, 2020
Aug 25, 2020
Feb 2, 2016

Repository files navigation

Babel Closure Elimination

This is a Babel plugin that eliminates unnecessary closures from your JavaScript in the name of performance.

Build Status

Note: Now requires Babel 6.

What?

Turns code like this:

function demo (input) {
  return input.map(item => item + 1).map(item => item + 2);
}

Into code like this:

function _ref(item) {
  return item + 1;
}

function _ref2(item) {
  return item + 2;
}

function demo(input) {
  return input.map(_ref).map(_ref2);
}

Why?

Because it's faster and more memory efficient in most JavaScript engines, and means you can safely use arrow functions without a performance penalty in most cases.

Installation

First, install via npm.

npm install --save-dev babel-plugin-closure-elimination

Then, in your babel configuration (usually in your .babelrc file), add "closure-elimination" to your list of plugins:

{
  "plugins": ["closure-elimination"]
}

License

Published by codemix under a permissive MIT License, see LICENSE.md.

About

A Babel plugin which eliminates closures from your JavaScript wherever possible.

Resources

License

Stars

Watchers

Forks

Packages

No packages published