Which code optimization tools are recommended?

What tools do you use to optimize the Javascript code?

Do you use the Google compiler?

How is the performance of the babel output or of the Typescript output?

Why isn’t the Google compiler integrated within Typescript?

I think you’re referring to uglifiers and minification. I’m not aware of any magic code optimizer. I believe Babel tries to make intelligent decisions on performance optimization, but it’s mostly all minor.

For uglification and minification I use Webpack.

Do you use the Google compiler?

From the description on the main site, Babel does all this already. I’ve honestly never heard of it or anyone using it and I’ve been a full time JavaScript engineer for about 3yrs now and a full stack developer for much longer.

Why isn’t the Google compiler integrated within Typescript?

Nothing is integrated in with Typescript, it’s a language. Typescript has it’s own compiler and has been integrated in with the Babel compiler since v7.

No I am not referring to uglification and minification. I am referring to code optimization like the Google compiler does.

Once I had a job developing browser games and they were using the Google compiler to increase performance.

Clojurescript uses the Google compiler. Other people use the Google compiler. Typescript can use it too.

It probably increases the build time to use this tool.

Once I had a job developing browser games and they were using the Google compiler to increase performance.

It doesn’t increase code performance, it does tree shaking. Which is very different and you’ll gain similar benefits from minification and uglification. You can combine all 3.

Webpack does tree shaking: https://webpack.js.org/guides/tree-shaking/

From the homepage:

What are the benefits of using Closure Compiler?

  • Efficiency. The Closure Compiler reduces the size of your JavaScript files and makes them more efficient, helping your application to load faster and reducing your bandwidth needs.
  • Code checking. The Closure Compiler provides warnings for illegal JavaScript and warnings for potentially dangerous operations, helping you to produce JavaScript that is less buggy and easier to maintain.

The MS article you linked seems to support this assumption as well.

The second point sounds like something that your linter should be doing. It was developed in 2009, so I wouldn’t be surprised if this was their way of linting back then. Go was also developed in 2009 and includes a linter built into the official compiler.

So, it does not seem to perform any code optimizations to increase actual code performance other than reducing payload size as much as possible. Google’s Compiler might or might not be better, but you’re really just looking at payload size and it’s not going to make a massive difference saving a few kbs. Personally, I prefer to use things that have larger support and documentation. So, I definitely recommend Webpack/Babel as they are basically the industry standard right now.

Clojurescript uses the Google compiler.

I realized my mistake and deleted that from my reply before you replied. :smiley:

To really know the facts, one must dig into the google compiler source code.

The documentation says it makes Javascript faster. How it does it is not very well documented.

I did not have time yet to dig into the source code. But I found several websites that say it makes Javascript faster.

And the creation of Clojurescript is led by Nathan Marz who has a good reputation for other frameworks he made.

Actually, there is documentation.

In particular, it does function inlining and dead code removal.

I foudn somewhere that several minification tools are not smart enough to do dead code removale.

I heard there is a way to move code to runtime loading.

It is clear better coding increases performance. Not much relying on a crazy tool.

INfernowas written to make react faster. Quite interesting what they say for increasing performance.

The MS article you link said it makes it faster by reducing the payload, which lets the user download it faster and gives less for the browser to parse. That’s true, it will. I haven’t seen anything saying it does anything else.

I guarantee everything it does, Babel or Webpack can do either natively or through a plugin.

I feel like you’re misplacing your optimization concerns. I would not rely on a magic tool to make your code faster or some off the wall library. React is very fast and only gets faster with every update. Anything new a library like Inferno does, I assure you that the core React team is aware of it and will evaluate it for the core library.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.