Live data from Hacker News

A Dive Into Plain JavaScript

blog.adtile.me

11–20 of 20 posts

Re: A Dive Into Plain JavaScript

#11
It's great to know what a library like JQuery is doing under the hood, but if you are going about your daily development using a progressive enhancement to access the dom using document.querySelector you are removing support for IE7 for no real reason.

You can query the dom in IE7 using other methods and this is the goal of a library like JQuery.

Progressive enhancements are aimed at providing an alternative for browsers that don't support functionality, not that don't support functionality the way you want to coded it.

Re: A Dive Into Plain JavaScript

#13

If learning JavaScript feels like jumping into the ocean and trying to swim for the first time, jQuery is, in some ways, like a motor boat driving beside you. The driver says, "Hey, hop on in. Why learn the basics of swimming when you can start covering ground?" Speaking from experience, failing to learn the foundational aspects of the language in the beginning leads to a lot of poorly organized "spaghetti" code. It…

I actually found that using backbone.js helped more with learning how to structure an app and about working with objects than writing vanilla javascript.

I was writing single-page applications just before jQuery was introduced, and I can tell you, my code was spaghetti because I didn't understand OO or functional design patterns. I didn't find jQuery to be a massive improvement in that, because I just linked data to DOM elements and everything was still all over the place.

Backbone forced me to write javascript in a cleaner way, even when I still didn't know what I was doing. I was breaking up my code into better methods and providing a better overall structure to my apps.

Now with Angular, I've taken that a step further to modularizing code, but I don't know how well I would have gotten on with Angular if I hadn't first learned so much from Backbone.

Re: A Dive Into Plain JavaScript

#14
Now I'm thinking about the need of MVC framework at the server side %-) Many of things you really need at the server side you can do without a framework and as a result you'll control/understand your code better.

Re: A Dive Into Plain JavaScript

#15
Plain JS is great! I love writing it.

That said, as a site (or app) grows, you generally end up writing more utility functions than you expected, and at some point it cancels out the benefits of NOT using jquery (or another lib). You have to weigh these decisions out, but saying "plain JS is better than jquery" is misleading since, in the end, jq is also written in plain JS. Think of it as all of those utility functions you DON'T have to write.

Just make sure you understand vanilla JS and I see no issues with leveraging libraries to make dev time faster. Those libs are generally tested enough to ensure cross-browser compatibility and save you the headache of rolling your own everywhere.

Re: A Dive Into Plain JavaScript

#16

Plain JS is great! I love writing it. That said, as a site (or app) grows, you generally end up writing more utility functions than you expected, and at some point it cancels out the benefits of NOT using jquery (or another lib). You have to weigh these decisions out, but saying "plain JS is better than jquery" is misleading since, in the end, jq is also written in plain JS. Think of it as all of those utility functi…

An even better solution is to use something like component.io or browserify. Then you still write mostly plain javascript, but can pull in small components and utilities when needed.

Re: A Dive Into Plain JavaScript

#17
There's a bug in the removeClass() function. If you use a class with a reserved regex character it will fail.

I'd rather see this done with a small sets library anyway. removeClass = function (el, cl) { el.className = _.without(el.className.split(' '), cl).join(' '); }

Re: A Dive Into Plain JavaScript

#18

If learning JavaScript feels like jumping into the ocean and trying to swim for the first time, jQuery is, in some ways, like a motor boat driving beside you. The driver says, "Hey, hop on in. Why learn the basics of swimming when you can start covering ground?" Speaking from experience, failing to learn the foundational aspects of the language in the beginning leads to a lot of poorly organized "spaghetti" code. It…

One of the main Problems with JavaScript is not the language itself, but the browser implementations. It was a huge pain to write cross-browser code when jQuery came out. jQuery took away a lot of these efforts and certainly had influence on the things you can do in modern browser these days, e. g. document.querySelector.

While I don't read your comment as a criticism of jQuery, I feel that jQuery gets bashed too often these days for insufficiencies in code. In the vast majority of cases such insufficiencies are not caused by the libraries, but by the developers using them.

Re: A Dive Into Plain JavaScript

#20

A couple more links on this topic: Vanilla JS vs jQuery https://gist.github.com/liamcurry/2597326 weaning yourself off jquery http://substack.net/weaning_yourself_off_jquery

> Vanilla JS vs jQuery https://gist.github.com/liamcurry/2597326

I checked this and it is an opinionated BS.

You can't just replace $.fn.ready with a 'DOMContentLoaded' event. 'DOMContentLoaded' is not supported in a older versions of IE.

Also what if instead of this: "var newDiv = $('')" I need this: "var newDiv = $('Some textSo overall that post is comparing apples to oranges.

Post reply on HN