2 ms·
It seems we're confounding the original question, then. My point more succinctly was, if you use only a select number of methods from jQuery, it would not be ha
by 52-6F-62 9y ago
It seems we're confounding the original question, then. My point more succinctly was, if you use only a select number of methods from jQuery, it would not be hard to emulate the syntax using modern JS methods and wrapping them in a small bit of logic in a much smaller file size than including jQuery itself. If size is an issue -- for some, it is. Current JS has made up for a lot of what jQuery originally was intended to fulfill (and again, most likely because of jQuery). And if it's just a syntactic reference, it's really easy to employ the same standard throughout your app with a pretty simple helper class.
edit: I extended the above example to include some of the methods you mentioned, just for kicks. The append() function was the most difficult, but only because I had to figure out how to grab the child function's selector argument. I just had to bind the initial argument to the object in the constructor. It was a fun little challenge. I'm likely missing some functionality of it, but I was going for quick and dirty implementation as simply as I could make it.
https://gist.github.com/Robert-Fairley/5e1ae9f84bf6072b708922122cdee424 https://gist.github.com/Robert-Fairley/5e1ae9f84bf6072b70892...
- dmitriid 9y ago> if you use only a select number of methods from jQuery, it would not be hard to emulate the syntax using modern JS methods and wrapping them in a small bit of logic in a much smaller file size than including jQuery itself. Question is: but why? :) What you do is basically re-implemeting jQuery with an untested code which is largely an unknown quantity. Whereas jQuery has countless little snippets like "We can't cloneNode fragments that contain checked, in WebKit"[1] any "simple, quick, dirty implementation" will not have that. It's better to use a "select number of methods from jQuery" directly from jQuery than spend any time re-implementing them anew and missing multiple details that jQuery has accumulated over the years. Even is size is an issue. If it really really is an issue, the best approach is to actually extract relevant code from jQuery and not re-implement it. My original point was: nothing in DOM APIs matches jQuery functionality. All attempts to prove anything otherwise only reinforce my point. [1] https://github.com/jquery/jquery/blob/master/src/manipulation.js#L139 https://github.com/jquery/jquery/blob/master/src/manipulatio...