And it is oh-so-ninja. It's 3Kb size. And 1.6Kb compressed with Closure. All in 87 LOCs. Beautiful recursion rocks.
Ninjas are stealthy. Carelessly adding four globals and modifying prototypes is not stealthy.
ƒu.js - The Functional DOM traversing library.
21–30 of 47 posts
Re: ƒu.js - The Functional DOM traversing library.
#22Earlier quoted context omitted.
It is nothing like jQuery. It's a small utility library for easing your life when dealing with raw javascript. You can use ƒ or fu.
It's a lot like jQuery's $ selector mechanism and fluent API. Here's some of your examples compared to their jQ equivalents: --- ƒ('selector1').ƒ('selector2').ƒ('selector3'); vs. $('selector1 selector2 selector3'); --- ƒ('body').style.background = '#f4f6f8'; vs. $('body')[0].style.background = '#f4f6f8'; --- for (var i=0; i vs. $.each($('ul'), function(index, ul) { for(var i=0; i --- I'm not even a jQuery user but I…
Re: ƒu.js - The Functional DOM traversing library.
#23Am I missing something here or do I really have to type the weird curly-F every time I want to call this? Having charmap open in my taskbar is not my idea of being productive. Plus, from my cursory glance this looks pretty similar, if not almost identical, to jQuery...
It is nothing like jQuery. It's a small utility library for easing your life when dealing with raw javascript. You can use ƒ or fu.
I can imagine it's handy if one wants something like the jQuery API but doesn't need support for all of the CSS selector features, or for older browsers, and wants to save a few bytes on downloads, given that it's much smaller (the uncompressed jQuery source is something like 60 times the size of this library, although in its defence that includes inline documentation).
Re: ƒu.js - The Functional DOM traversing library.
#24Why would you use this over normal querySelector{All}? Also, why do you define a window.typeOf global? It completely defeats the purpose of using a clousure. You also seem to be checking `typeof value.length == 'number' && typeof value.splice != 'undefined' && !value.propertyIsEnumerable('length')` to determine if something is an Array. First of all, the recommended practice is to check Object.prototype.toString.call…
This may be irrelevant to original comment but does querySelector work in all modern browsers? My understanding was that it doesn't and so there is need for CSS selector engines like jQuery's sizzle.
> http://help.dottoro.com/ljlumkqh.php
The page implies that there is limitations to the IE8 implementation, and that it's only available in relatively recent browsers. In addition, I believe that sizzle implements a set of selectors larger than most or all browsers support natively, although this I am less sure of; the Sizzle documentation certainly implies it strongly:
Re: ƒu.js - The Functional DOM traversing library.
#25Earlier quoted context omitted.
It's a lot like jQuery's $ selector mechanism and fluent API. Here's some of your examples compared to their jQ equivalents: --- ƒ('selector1').ƒ('selector2').ƒ('selector3'); vs. $('selector1 selector2 selector3'); --- ƒ('body').style.background = '#f4f6f8'; vs. $('body')[0].style.background = '#f4f6f8'; --- for (var i=0; i vs. $.each($('ul'), function(index, ul) { for(var i=0; i --- I'm not even a jQuery user but I…
In the author's defence, the Fu.JS syntax is much nicer than the jQuery syntax, so I can see why someone would want to build this.
How? No, seriously, how is
ƒ('body').style.background = '#f4f6f8';
much nicer than $('body').css('background', '#f4f6f8');
? fu().body.fu('ul').appendChild(ƒ().createElement('li'));
than $('body ul').append($(''));
? document.body.ƒ('ul li:last-child').innerText = "I'M THE NEW GUY!";
than $(document.body).find('ul li:last-child').text("I'M THE OLD GUY!");
? for (var i=0; i
than for (var i=0; i'));
}
? ƒ('ul li:nth-child(2n)', 'style.background = "black"')
than $('ul li:nth-child(2n)').css('background', 'black')
?Re: ƒu.js - The Functional DOM traversing library.
#26Earlier quoted context omitted.
In the author's defence, the Fu.JS syntax is much nicer than the jQuery syntax, so I can see why someone would want to build this.
> In the author's defence, the Fu.JS syntax is much nicer than the jQuery syntax How? No, seriously, how is ƒ('body').style.background = '#f4f6f8'; much nicer than $('body').css('background', '#f4f6f8'); ? fu().body.fu('ul').appendChild(ƒ().createElement('li')); than $('body ul').append($(' ')); ? document.body.ƒ('ul li:last-child').innerText = "I'M THE NEW GUY!"; than $(document.body).find('ul li:last-child').text("…
$('body ul').append($(''));
can become: $('body ul').append('');
and: $(document.body).find('ul li:last-child').text("I'M THE OLD GUY!");
can become: $("body").find('ul li:last-child').text("I'M THE OLD GUY!");
(We optimize for body explicitly in our selector code.) Although that last example selector is rather weird, it's equivalent to: $("body ul li:last-child")
or even just: $("ul li:last-child")
(When is a ul ever going to be outside of a body element?)Re: ƒu.js - The Functional DOM traversing library.
#27E.g.:
try {
eval('el.' + argv[1]);
return el;
} catch(e) {
return null
};
Why in the world would you do this? JavaScript has property access via bracket syntax for a reason: return el[argv[1]] || null;
Give this a read: https://developer.mozilla.org/en/a_re-introduction_to_javasc...Re: ƒu.js - The Functional DOM traversing library.
#28Earlier quoted context omitted.
Ouch. There is value in being able to handle extremely harsh criticism. There is also value in being able to say things nicely, with the knowledge that your words will be more easily heard by the person on the other end, and put to use rather than dismissed out of anger.
There's also value in being right, which he definitely is. Whether anyone likes it or not, brutal honesty pushes everything forward.
Re: ƒu.js - The Functional DOM traversing library.
#29I like one-file less-than-100-LOC type libs.
It's not really meant for general purpose. Just for projects where you want raw javascript performance and need a little help for traversing and manipulation of DOM elements as arrays. Like my Chrome extension: Sight: https://github.com/tsenart/sight .
e.g. Sizzle('div:first')
Re: ƒu.js - The Functional DOM traversing library.
#30Why would you use this over normal querySelector{All}? Also, why do you define a window.typeOf global? It completely defeats the purpose of using a clousure. You also seem to be checking `typeof value.length == 'number' && typeof value.splice != 'undefined' && !value.propertyIsEnumerable('length')` to determine if something is an Array. First of all, the recommended practice is to check Object.prototype.toString.call…
I think you bring up valid points, but you should work on delivery. Your post is very offensive to read, even from someone who has no stake in this library whatsoever - even though I think you're right. You've also got a lot of typos. So, try to be helpful and encouraging instead of damning and dismissive? I'd appreciate that, and be more open to what you're saying.