GithubHelp home page GithubHelp logo

optimize's Introduction

optimize

JavaScript code optimizer Build Status Code Coverage

usage

var optimize = require('optimize');
optimize('console.log(1+1);'); //"console.log(2);"

optimize's People

Contributors

zoltan-mihalyi avatar

Stargazers

Valentin Vichnal avatar

Watchers

James Cloos avatar  avatar

optimize's Issues

handle extra scopes at foreach and function expression

The name "a" is in a scope which is different from the scope of the block.

(function a(){
  //a is accessible but can hide with local vars.
});

The same applies to this:

for (let a in x){
  //a is accessible but can hide with local vars.
}

fix iteration on replacing array

            for (let j = 0; j < sub.length; j++) {
                const lengthBefore = sub.length;
                let result:T = (sub[j] as SemanticNode).walk(before);
                j -= lengthBefore - sub.length;
                if (result) {
                    return result;
                }
            }

don't remove directives

In some cases (in angular optimization) we are removing directives.
Maybe it is a parser bug.

toBoolean

we could reduce not operator in the same way as we do in conditional reduction

target version option

target=es5:
More native function can be substituted
target=es6:
More native functions and other optimizations

variables with predictable values in inner scopes should be used

function fn() {
    function declaration(){
    }
    return () => {
        return [typeof arguments, typeof declaration];
    }
   declaration = function(){};
}

In the code above, the typeof expressions are predictable.
Use "effectiveValue" which is the all possible values of the variable. This should be used in try block tracking

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.