Why do I bother trying to write correct javascript

For the more technical/geeky chat subjects!

Moderator: satrow

thosrtanner
Fanatic
Fanatic
Posts: 149
Joined: Sat, 10 May 2014, 18:19
Location: UK

Why do I bother trying to write correct javascript

Unread postby thosrtanner » Mon, 18 Dec 2017, 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: 22424
Joined: Sun, 28 Aug 2011, 17:27
Location: 58.5°N 15.5°E
Contact:

Re: Why do I bother trying to write correct javascript

Unread postby Moonchild » Mon, 18 Dec 2017, 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.
Improving Mozilla code: You know you're on the right track with code changes when you spend the majority of your time deleting code.

"If you want to build a better world for yourself, you have to be willing to build one for everybody." -- Coyote Osborne

thosrtanner
Fanatic
Fanatic
Posts: 149
Joined: Sat, 10 May 2014, 18:19
Location: UK

Re: Why do I bother trying to write correct javascript

Unread postby thosrtanner » Mon, 18 Dec 2017, 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: 22424
Joined: Sun, 28 Aug 2011, 17:27
Location: 58.5°N 15.5°E
Contact:

Re: Why do I bother trying to write correct javascript

Unread postby Moonchild » Mon, 18 Dec 2017, 21:28

It's not your task to troubleshoot that website, is it?
Improving Mozilla code: You know you're on the right track with code changes when you spend the majority of your time deleting code.

"If you want to build a better world for yourself, you have to be willing to build one for everybody." -- Coyote Osborne

thosrtanner
Fanatic
Fanatic
Posts: 149
Joined: Sat, 10 May 2014, 18:19
Location: UK

Re: Why do I bother trying to write correct javascript

Unread postby thosrtanner » Tue, 19 Dec 2017, 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
Lunatic
Lunatic
Posts: 259
Joined: Mon, 28 Sep 2015, 16:38
Location: US
Contact:

Re: Why do I bother trying to write correct javascript

Unread postby joe04 » Wed, 20 Dec 2017, 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
Moongazer
Moongazer
Posts: 12
Joined: Sat, 09 Dec 2017, 10:34

Re: Why do I bother trying to write correct javascript

Unread postby franzk » Wed, 03 Jan 2018, 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...


Return to “Technical chat”

Who is online

Users browsing this forum: No registered users and 1 guest