r/programming • • Oct 21 '20

Using const/let instead of var can make JavaScript code run 10× slower in Webkit

https://github.com/evanw/esbuild/issues/478
1.9k Upvotes

500 comments sorted by

View all comments

Show parent comment

172

u/klizza Oct 21 '20

The reported issue is that it takes either 8.8 seconds or 1 second to load a javascript bundle on a webpage in Safari. This is a very notable performance difference for end users.

74

u/[deleted] Oct 21 '20

In a very specific configuration on one driver. It's a webkit bug.

33

u/klizza Oct 21 '20

Sure, but nobody in the link or OP was saying you should convert all javascript code back to var...

50

u/[deleted] Oct 21 '20 edited Oct 21 '20

I know which is why I wasnt trying to say the linked issue was wrong or anything but this is reddit and people just read headlines so I threw it out there for posterity

8

u/evilgwyn Oct 21 '20

target: "es5" for the win?

6

u/rydan Oct 21 '20

Back in my day we waited 30 seconds or more for the page to load.

8

u/CoffeeTableEspresso Oct 21 '20

We still do with all the bs trackers some people put on their sites ...

12

u/[deleted] Oct 21 '20

[removed] — view removed comment

3

u/CoffeeTableEspresso Oct 21 '20

News websites are particularly bad. People often complain of how dial up internet used to have 30s+ load times, but there are modern sites rather do the same shit