Why do I bother trying to write correct javascript

General discussion and chat (archived)
thosrtanner
Lunatic
Lunatic
Posts: 395
Joined: 2014-05-10, 18:19
Location: UK

Why do I bother trying to write correct javascript

Unread post by thosrtanner » 2017-12-18, 12:22

I have js warnings switched on so I can get some sort of confidence that my extension isn't doing something wacky. Though pretty much the only stuff I'm getting is some trace I've added while I refactor part of it.

But this sort of thing depresses me:

SyntaxError: test for equality (==) mistyped as assignment (=)? 0W-sSTssQ2I.js:10:2191
SyntaxError: 'use strict' statement won't be enforced as a directive because it isn't in directive prologue position 0W-sSTssQ2I.js:18:729
SyntaxError: 'use strict' statement won't be enforced as a directive because it isn't in directive prologue position 3fvKUm1gRWA.js:10:456
SyntaxError: 'use strict' statement won't be enforced as a directive because it isn't in directive prologue position 3fvKUm1gRWA.js:11:233
TypeError: useless expression 3MxwccAAarv.js:3:2587
ReferenceError: reference to undefined property this.$Dispatcher_DEPRECATED1[m] NQ0NO8kcQHe.js:3:1850
ReferenceError: reference to undefined property M.$$typeof A2RCaiQ_wsN.js:38:2175
TypeError: "name" is read-only


and that's just an excerpt of the piles of junk I can get when I load a web page.

I mean 'use strict' not being enforced. The coder couldn't even get that right?

There are days when I wonder why the web works at all.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35576
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Why do I bother trying to write correct javascript

Unread post by Moonchild » 2017-12-18, 14:25

And if you look at the actual names of the files you can see this junk is generated -- so most likely part of some broken framework that's only tested against Chrome. The site owners using it probably don't even know what a browser console is.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

thosrtanner
Lunatic
Lunatic
Posts: 395
Joined: 2014-05-10, 18:19
Location: UK

Re: Why do I bother trying to write correct javascript

Unread post by thosrtanner » 2017-12-18, 20:59

Well, one of the libraries that produces these sorts of messages is jquery

I get quite a log of the undefined property and test for equality mistyped messages when using this website

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35576
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Why do I bother trying to write correct javascript

Unread post by Moonchild » 2017-12-18, 21:28

It's not your task to troubleshoot that website, is it?
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

thosrtanner
Lunatic
Lunatic
Posts: 395
Joined: 2014-05-10, 18:19
Location: UK

Re: Why do I bother trying to write correct javascript

Unread post by thosrtanner » 2017-12-19, 19:59

Didn't suggest it was. However, it's occasionally quite hard to spot warnings caused by my code in the spew of warnings from websites. Especially at startup.

It is an annoyance I can get round but it is definitely an annoyance.

joe04

Re: Why do I bother trying to write correct javascript

Unread post by joe04 » 2017-12-20, 18:12

thosrtanner wrote:There are days when I wonder why the web works at all.
You know the technical details better than I, but thinking big picture, this is a good reminder of the long history of browsers being very accomodating of crappy code. The web wouldn't have grown by leaps and bounds 20 years ago without it. And the fact that the various methods of accomodating crappy markup, scripting, etc. have been to a large extent codefied as WHATWG standards is quite interesting.

And think about it from the webdev perspective. If the crap you write "just works" in Chrome, like Moonchild said, then "ship it". Especially if they don't care one bit about quality of craftmanship, just quick&dirty results.

franzk

Re: Why do I bother trying to write correct javascript

Unread post by franzk » 2018-01-03, 21:28

Pretty trivial to encourage web developers to understand javascript better, disable just in time compilation for non compliant code, similar to Google's solution of calling everything "not secure" that isn't compliant with their vision of HTTPS for everything.

It'd be a pretty big stick, developers would have to write proper javascript for performance. Would only work if Google decided it would be so though...

Locked