
JQuery++ - ausjke
http://jquerypp.com/
======
overcast
My last two projects have completely forgone jQuery for vanilla JS and a
minimal Lodash. Widespread support for querySelector, querySelectorAll,
getElementById eliminate all of those handy selector functions. The rest you
can read below.

[http://youmightnotneedjquery.com/](http://youmightnotneedjquery.com/)

This also helps you to learn better javascript, rather than relying on a
crutch to string together a lot of convoluted sugar syntax.

~~~
recursive
Ajax is the last thing keeping me in jquery.

~~~
overcast
From my original link above.

[http://youmightnotneedjquery.com/](http://youmightnotneedjquery.com/)

var request = new XMLHttpRequest(); request.open('GET', '/my/url', true);

request.onload = function() { if (request.status >= 200 && request.status <
400) { // Success! var data = JSON.parse(request.responseText); } else { // We
reached our target server, but it returned an error

    
    
      }

};

request.onerror = function() { // There was a connection error of some sort };

request.send();

OR

Even better, you should just use a reactive front end framework.
[https://vuejs.org/](https://vuejs.org/) combined with
[https://github.com/vuejs/vue-resource](https://github.com/vuejs/vue-resource)
is currently my fave.

~~~
NDizzle
You don't need jquery!!! You need... these other things that fewer people use
and/or care about.

Just use jQuery. Please.

~~~
overcast
You don't need a reactive front end framework, but not using two way data
binding at this point I think is crazy. Binding is an EXTREMELY powerful tool.

~~~
NDizzle
I have yet to see something that handles updates from other sources well.
Meaning that the page the user is on is updated by some other person or
process and those changes are propagated correctly. I still have events that
fire when something is saved that check to see if it was modified while the
user was in it.

------
mkoryak
OK serious question about NOT using jquery.

I am an author of a jquery plugin (1KLOC) which I need to rewrite in plain js.

There is going to be a handful of things that when converted will need to
become helper methods because its not a line to line conversion.

So now Ill be writing a small dom manipulation lib within my lib. This seems
wrong to me, since every other thing converted from jquery to native will also
need write their own little helper lib.

Now you import all these great native js libs into your project, and because
native js code is usually a little bigger than jquery code, you end up with a
bigger vendor bundle than if you had just used jquery and all your libs used
it too.

what is the advantage of that?

~~~
chillydawg
Could you not rely on a tiny dom manipulation lib?

~~~
mkoryak
yes, I think that is a solution. ill probably end up writing my own though,
with just stuff I need. Otherwise its just like jquery all over again

------
kdbuck
Looks cool. I am personally looking for more reasons to drop jQuery rather
than more reasons to depend on it though. As an aside, I did the swipe to see
the menu (I'm on mobile) but I am having hard time making the menu go away.
(currently using _gasp_ refresh).

------
timwaagh
I like some of these functions. The cookie function is something i could have
used in the past. And the selection function seems handy too. But I think the
web site could use a lick of paint.

------
oldboyFX
All of these comments taking a crap on jQuery are hilarious.

It's like saying "Using lodash is bad because then you don't learn real
javascript and you rely on another big library to do the job for you".

Becoming an expert DOM manipulator in vanilla javascript won't make you a good
developer. DOM manipulation is incredibly trivial but involves a lot of grunt
work, and jQuery is just a utility lib that makes the grunt work easier. Just
like lodash, moment.js or any other lib.

I think people are just super salty because jQuery is popular, everyone uses
it, which means that a lot of bad developers use it, and bad developers
produce spaghetti code - which means that jQuery is bad? lol.

You know there's a lot of morons who eat pizza, does that mean that ordering
pizza once in a while makes you a moron?

Writing good or bad code has nothing to do with jQuery, lodash, React, or any
other library.

If you're a shit programmer you will write shit code. If you're a good
programmer you won't.

If you're rendering server side, you're going to use imperative DOM
manipulation library - jQuery is a good choice.

If you're rendering client side, you don't need jQuery, you're going to use a
rendering library.

I don't get why people have problems with grasping such simple concepts.

/rant

------
encoderer
With react and redux I haven't needed jQ for anything in ages. Feels
fantastic. A whole class of bugs is avoided when you aren't poking at the DOM
to get things done.

------
sharmi
For all those who suggest, vanilla JS, it sounds quite interesting, but many
use ui frameworks like bootstrap which require jquery anyway. So why not go
the whole distance and use jquery yourself?

Can bootstrap work without jquery or isolate only the subset of jquery they
use?

~~~
subsection1h
This isn't precisely what you asked for, but there are versions of Bootstrap
without jQuery for some client-side frameworks:

[http://react-bootstrap.github.io/](http://react-bootstrap.github.io/)

[https://reactstrap.github.io/](https://reactstrap.github.io/)

[https://github.com/ng-bootstrap/core](https://github.com/ng-bootstrap/core)

[https://kaliber5.github.io/ember-
bootstrap/](https://kaliber5.github.io/ember-bootstrap/)

[http://yuche.github.io/vue-strap/](http://yuche.github.io/vue-strap/)

[https://github.com/ng-vu/mithril-bootstrap](https://github.com/ng-vu/mithril-
bootstrap)

[http://cognitom.github.io/riot-bootstrap/](http://cognitom.github.io/riot-
bootstrap/)

------
buckbova
Not that I need another framework but looks like this is in use with donejs.

[https://github.com/donejs/donejs](https://github.com/donejs/donejs)

Looks interesting. Has anyone tried this?

~~~
marshallswain
I've enjoyed using DoneJS. It's a lot like using Vue or using React with Mobx.
I really like how it provides a lot of things that I'd normally have to set up
myself, like SSR, & fall-through data cacheing, and its packager/build tool
has the best API of the ones I've used (but I've only seriously used
Browserify, Webpack, & StealJS, and SystemJS a little bit, so I can't speak
for the others). It supports using React for the view layer, if that's your
thing. Also, full disclosure, because of my past experience with DoneJS-
related projects, I got a position at Bitovi last year. It's pretty likely
you've used sites that use DoneJS tech, too. I know of at least one in the
Alexa top 50. I REALLY like the changes of the next version, which is
currently available as a pre-release on npm. I've been using it in my side
projects and it has some pretty nice changes to many of the APIs.

------
oneweekwonder
Personally I don't try to use jQuery anymore. Don't get me wrong. I use it a
lot, even in new projects. Because a lot of third party libraries,
applications or components depend on it.

Also jQuery is so much intrenched into our computer infrastructure. You can
even install it using your fav package manager `apt-get install libjs-jquery`.

------
nateabele
I appreciate that jQuery got us to where we are today, but as far as best
practices go, I don't think we should encourage its current use.

The best we could do for a 'replacement' is a site that lets you pick which
browsers you're targeting, which DOM APIs you want, and generates a polyfill.

~~~
seanp2k2
Caniuse.com + Modernizr +
[https://github.com/Polyfiller/polyfiller](https://github.com/Polyfiller/polyfiller)
or Webshim?

------
halestock
How can I know this is safe (short of reading the downloaded source)? There's
(apparently) no relation to the actual jquery project, and the downloads are
being served over http.

~~~
marshallswain
It's on npm, too, if that's a better option for you.
[https://www.npmjs.com/package/jquerypp](https://www.npmjs.com/package/jquerypp)

