Hacker News new | ask | show | jobs
by aikah 4052 days ago
Obviously PlainJS author isn't going to do the debugging for you when a client calls you at 2am to ask you why some widget is broken on an old version of webkit on his android.

Because that's why serious front-end developers use jQuery. Because the jQuery team actually tests the code against a wide range of browsers. All these libs hacked in an afternoon are lucky if they have at least some tests...

And again, the DOM=/=Javascript. Jquery is as vanilla JS as all these libs. But some people still can't tell the difference. An API isn't the language. There is no "document.createElement" in the Javascript spec.

3 comments

Plain JS is better suited for developers who are writing large apps. jQuery is a nightmare to maintain in large applications and popular SPA apps have foregone jQuery (except Backbone.js). jQuery has its place in small websites that don't do much but when you need to code logic into things, jQuery is just not suitable.
The problem with the DOM is the DOM itself and how it is written. React decided to abstract it completely, AngularJS decided to bundle its own version of jQuery with it and try to restrict DOM manipulations within directives. But both still do DOM manipulation under the hood, whether it is with jQuery or framework X it doesn't matter, provided the DOM abstraction works on a wide range of browsers and is extensively tested.

But what is wrong is saying jQuery isn't plain JS or "Vanilla JS". Which is stupid since jQuery IS a DOM abstraction and any javascript library written in javascript is plain or vanilla js. It can only mean that the person who says that doesn't know the difference between the DOM and Javascript.

I think we're all aware jQuery is written plain JS and it's not an own language ... it's an abstraction layer. The question is: Is it still necessary - or is it becoming obsolete, because nativly in browsers implemented DOM has evolved to the point where an abstraction layer isn't making things easier any more.

So, why use an abstraction layer if the base layer itself offers quite the same comfort?

If you're using jquery to make apps instead of an app framework like react or angular, you are guaranteed to be writing spaghetti. If you're using it to enhance pages sent from the server, it's hard to call that "serious".
> If you're using jquery to make apps instead of an app framework like react or angular, you are guaranteed to be writing spaghetti.

This is just flat out wrong. Frameworks provide a layer (or multiple layers) of abstraction to make code organization and maintenance easier. How that translates into "guaranteed to be writing spaghetti" I have no idea; those frameworks can't force you into their coding structure and you can still write absolutely horrible spaghetti in them (I've seen some really bad angular that should have been simply set on fire and re-written).

In fact you can write horrible spaghetti using basically any language or framework. It comes down to discipline and experience, in my opinion, when you want to write clean and easy-to-maintain code.

> If you're using jquery to make apps instead of an app framework like react or angular, you are guaranteed to be writing spaghetti.

I definitely do not need react or angularjs. Trust me I don't.

Because I know and respect SOLID principles and I don't need a framework to enforce them.

If you can't tell what should be in the view from where your business logic should be OR you need a framework to enforce these principles then you're going to write spaghetti code no matter what, jQuery or not, react,angularjs or not.

And by the way Angular 1.x works quite well with jQuery, Angular 1.x even includes a light version of jQuery.

"There is no "document.createElement" in the Javascript spec." Uh... https://developer.mozilla.org/en-US/docs/Web/API/Document/cr...
Yes, document.createElement exists and is documented. But check the links at the bottom of the page: the function comes from the DOM and HTML5 specs, not from the Javascript spec.
Your link actually shows it's not part of the EMCAScript specification :)

No worries just a common misconception; the DOM API is part of HTML and DOM specifications.

Yeah well , this IS the ecmascript AKA javascript spec :

https://es5.github.io/

you pointed to a mozilla wiki which has a entry under "web" directory

     >"There is no "document.createElement" in the Javascript spec." Uh... https://developer.mozilla.org/en-US/docs/Web/API/Document/cr...
well, I hope you learned something today because your link isn't the javascript spec.