News for hackers. Stuff that matters.

Nasmon

Re:PlainJS – The Vanilla JavaScript Repository on Wednesday May 13, 2015 @03:15PM (#9541294)
Thanks for your hint! It would be interesting to know which IE versions are affected.

Code on plainJS has no unit tests (so far) and it's objective is a) recommending useful and field tested vanilla JS plugins and b) provide useful code snippets for writing simple JavaScript driven sites without the help of jQuery.

The snippets are tested in all major browsers, but sure, at the current stage - there are rather likely some minor bugs here and there. Yet, I think it's pretty helpful to see the principle of how things are done without jQuery. So, even if there is a bug somewhere, the snippet still points into the right direction.

Re:PlainJS – The Vanilla JavaScript Repository on Wednesday May 13, 2015 @03:06PM (#9541246)
> parents('.classname')

In DOM4, which is available in modern browsers: .closest('.classname') possibly also .parent('.classname'), but haven't looked it up.

Re:PlainJS – The Vanilla JavaScript Repository on Wednesday May 13, 2015 @03:02PM (#9541211)
jQuery is perfect for rather complex JS driven websites, e.g. web page builders. But most websites that make use of jQuery just don't need it.

As an example website we created without jQuery: plainJS.com :-P The site provides a neat interface with features like autocomplete search and syntax highlighting. And the whole page works nicely down to IE 8.

I was surprised how simple it is - and in the process we've also released some Vanilla JS plugins. Also, I was surprised how many modern Vanilla JS plugins there already are!

So where would be the point to use jQuery on plainJS.com? It neither makes development or maintenance easier, nor is it faster - but it add a third party dependency.

Re:PlainJS – The Vanilla JavaScript Repository on Wednesday May 13, 2015 @02:23PM (#9540945)
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?

Re:PlainJS – The Vanilla JavaScript Repository on Wednesday May 13, 2015 @12:30PM (#9540119)
Fixed it :-) Thanks.
Re:PlainJS – The Vanilla JavaScript Repository on Wednesday May 13, 2015 @12:23PM (#9540082)
The mass of try-catch and the likes simply isn't necessary any more. JS has grown up. IE 8 is still nasty, but if required, one can handle it.
Re:PlainJS – The Vanilla JavaScript Repository on Wednesday May 13, 2015 @12:21PM (#9540069)
It's not just about performance. That can be important for complex projects, such as image editors, but it's not why I personally prefer plain JS over jQuery.

However, ask yourself: What's your advantage of using jQuery today? Modern JS is pretty cross browser safe and syntax is becoming simpler and simpler. Modern browsers, like Chrome or FF, have already DOM4 implemented. With that, a lot of jQuery-like methods were accepted: .prepend(), .closest() ... querySelectorAll() is essetially the same es $(...) in jQuery.

Personally, I was surprised how easy and effective it is to write vanilla JS. Which is why the idea of plainJS.com came up. And as a proof of concept, plainJS is naturally fully implemented in plain JS :D And it wasn't hard, and it works properly down to IE 8.

Re:PlainJS – The Vanilla JavaScript Repository on Wednesday May 13, 2015 @12:15PM (#9540016)
Answering in the name of Pixabay: We started Pixabay years ago and at the time, jQuery was kind of the holy grail in terms of cross browser safe JS development. However, times change and today we would use vanilla JS for the site. And the day will come when we finally take the time to rewrite the code.

Yet, I totally admit, there are use cases where jQuery is still extremely useful. E.g. online web page editors, such as Wix.com or HubPages.com ...

I actually love jQuery! Yet, plain JS has become pretty cross browser safe and once familiar with it, it isn't harder to develop most sites in vanilla JS.

Also, useful methods previously known only to jQuery get accepted as DOM methods. E.g. DOM4 includes methods like .closest(), .append(), or .prepend(), etc. This makes plain DOM manipulation similarly readable as jQuery. But it's not yet widely supported ...