---
title: "Discussion on \"Top 10 JavaScript Hack for Optimized Performance\" | Hashnode"
description: "Discussion on \"Top 10 JavaScript Hack for Optimized Performance\". JavaScript has been ruling the tech arena for more than two decades and helping developers simplifying complex tasks. It allows developers to implement complex task web pages in a most simplified manner. For most of the developers minified JavaScript..."
url: "https://hashnode.com/posts/top-10-javascript-hack-for-optimized-performance/5d02400736a0034c13ed018c"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Top 10 JavaScript Hack for Optimized Performance](https://ronak.hashnode.dev/top-10-javascript-hack-for-optimized-performance?utm_source=hashnode&utm_medium=feed)

JavaScript has been ruling the tech arena for more than two decades and helping developers simplifying complex tasks. It allows developers to implement complex task web pages in a most simplified manner. For most of the developers minified JavaScript...

Jun 13, 2019 · ronak.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#javascript-framework](https://hashnode.com/tag/javascript-framework)
-   [#javascript-library](https://hashnode.com/tag/javascript-library)

## Written by

[Ronak Patel](https://hashnode.com/@Ronak)

@Ronak · India

  
[View profile](https://hashnode.com/@Ronak)

Co Founder | CEO @ Aglowid IT Solutions

Ronak is the Co-founder and full stack developer of Aglowid IT Solutions, a company that specializes in Full Stack website development for Startups as well as businesses organizations. With the prolonged experience in business management and Web Development, Ronak is intimate with the challenges to work on unique concepts and ideas. Ronak is always in thirst of knowing the latest technologies which helps him consult and provide the best possible solution that his clients requires.

## Responses 1

Markdown supported · ⌘↵ to post

[Agnius Vasiliauskas](https://hashnode.com/@AgniusVasiliauskas)

[Jun 14, 2019](https://hashnode.com/posts/top-10-javascript-hack-for-optimized-performance/5d02400736a0034c13ed018c/comment/5d03909bbf4e2c1e5aeba286)

Nice article, I especially liked part about HTTP/2 multiplexing, indeed - every web server should make this requirement a **MUST HAVE**. However I can't agree on your note that :

> Using the Switch case over if/else enables developers to shorten execution time

I can't believe in this - at a lower level **both** code structures should be compiled into some sort of _goto_ conditional jumps. Let's check. I've made a JS benchmark. This is switch block:

```
var rnd = Math.floor(Math.random() * 5);
switch(rnd) {
  case 1:
    rnd += 1;
    break;
  case 2:
    rnd += 2;
    break;
  default:
    rnd += -1;
}
```

and this is if/else block :

```
var rnd = Math.floor(Math.random() * 5);
if (rnd == 1) {
    rnd += 1;
}
else if (rnd == 2) {
    rnd += 2;
}
else {
    rnd += -1;
}
```

After pasting these blocks into [jsbench.me](https://jsbench.me/) performance comparison suite,- I've got results that **switch** block is SLOWER by _\[0% - 2%\]_ on average. Given many unknown factors - how these tests are executed, JS implementation differences between browsers, execution speed measurement errors, biased outcome (maybe after 1000 or more runs performance difference would be 0%) and etc. - it would be rational to neglect these small execution time differences and for practical purposes keep that both should run at the same rate.
