top | item 41200259

(no title)

cronin101 | 1 year ago

> the execution of JS code it down to the browser rendering the page where it’s deployed. As such it’s practically impossible to get any code to run consistently

Can you elaborate on this part? I would say one of the strengths of JS is that you can get it to run consistently just about anywhere.

discuss

order

bubblebeard|1 year ago

Certainly! Now, I’m no expert and may get some things wrong here, if anyone else knows better I’d be happy to be corrected.

Every browser implements a version of ECMAScript (this is a specification declaring what features of the JS language will be available for the JS engine included with the browser).

This means that every browser on the planet, and every version of them, support different JS features.

For example, let and const are commonly used to define variables, but if someone happens to use an old browser version the use of these would cause an error, which in turn may cause all the rest of JS code to stop executing, resulting in (worst case scenario) your website being rendered useless to that particular person.

On top of that different browsers may use different engines. So even if they define the same ES version the code may still execute differently (this was for example a very big issue with Microsoft browsers in the past).

This may seem trivial, but new JS features emerge all the time. Granted, this was a much bigger problem before ~2015 something, but it’s by no means none existent today.

Thus, you cannot be sure the code you write locally will actually function the same everywhere, and you are unlikely to know how often failures even occur since it all happens client side.

cronin101|1 year ago

I think with the official deprecation of IE this is mostly a thing of the past since all major browsers are “evergreen” and support a pretty recent standard. This certainly was the case only a couple of years ago, and it’s almost always wise to have a bundler (e.g webpack) that can target a fixed standard as output via transpilation/polyfill just in case you are itching to use the experimental features.