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($('<li>'));
? 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 < 50; i++) {
ƒ('ul').appendChild(ƒ().createElement('li'));
}
than for (var i=0; i<50; ++i) {
$('ul').append($('<li>'));
}
? ƒ('ul li:nth-child(2n)', 'style.background = "black"')
than $('ul li:nth-child(2n)').css('background', 'black')
? $('body ul').append($('<li>'));
can become: $('body ul').append('<li>');
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?) document.body.ƒ('ul li:last-child').innerText = "I'M THE NEW GUY!";
That code won't work in standards-compliant browsers. You should either use .textContent = "..." or .appendChild(document.createTextNode("...")) or .firstChild.wholeText = "..." if there's already a text node child.The real issue though is that unlike jQuery, ƒu.js won't work in popular versions of IE.
> (When is a ul ever going to be outside of a body element?)
Document fragments? XML documents? Not sure you can use that style of jQuery calls on those, but~~
some of the fu.js lines are a bit unwieldy but at least it's obvious to me what they do - i found jQuery code pretty bewildering until i delved into it
Unless, of course, you've spent roughly 5mn reading upon how jQuery's getting and setting works. Then you know the first argument is a key and the second one is a value to set.
I can see you've also quickly moved the goalposts, from "fu.js's syntax is much nicer" (emphasis yours) to "I claim to undetstand what fu.js does without having read its documentation"
---
ƒ('selector1').ƒ('selector2').ƒ('selector3');
vs.
$('selector1 selector2 selector3');
---
ƒ('body').style.background = '#f4f6f8';
vs.
$('body')[0].style.background = '#f4f6f8';
---
for (var i=0; i < 50; i++) { ƒ('ul').appendChild(ƒ().createElement('li')); }
vs.
$.each($('ul'), function(index, ul) { for(var i=0; i < 50; i++) { ul.appendChild(document.createElement('li')); } });
---
I'm not even a jQuery user but I don't see a lot of difference in your approach versus jQuery's here. I already only use lightweight libraries like jQuery or Ext.Core for situations which call for only minor Javascript (read: not an RIA).
In what situations do you imagine your framework is more useful?