5 ms·
JQuery.ish - A Simpler jQuery
- bentlegen 14y ago"This project is NOT to ... create a plugin that is more than 500 bytes minified and gzipped" It's already at 483 bytes. Where do you go from here?
- huragok 14y agoDown! :)
- amyhackernews 14y agoI'd personally be pretty happy with < 2K. The main things I use jQuery for are: 1) selecting nodes (especially children of selected nodes), 2) manipulating node attributes, 3) AJAX, 4) extend(), 5) animating CSS, 6) normalizing some events.
- yaix 14y agoHow about 400 Bytes?
- cageface 14y agoIt seems like only yesterday that jQuery was the simple, lightweight alternative. I wonder how long it will be before things like this and Zepto add enough features to earn accusations of bloat.
- buddydvd 14y agoCan Google Closure Compiler compile an app with jQuery but only include parts of jQuery that the app depends on?
- ehsanu1 14y agoYes, but not directly (jQuery is not written in a compatible way for dead code removal). Instead, use https://github.com/zgrossbart/jslim https://github.com/zgrossbart/jslim
- buddydvd 14y agoThis is great. Thanks for the link! The example in the readme suggests that jslim can reduce simple apps combined with jQuery by up 28%. I wonder if it can achieve more if jQuery was modified to let you specify selectors by function calls instead of selector string. For calls like $("a.button"), the static analyzer may have trouble removing unused code such as the parts that deal with descendant selector, ID selector. If selectors where specified as function calls like $.find($.byTag("a").byClass("button")), static analyzer may identify and remove more dead code. Though it probably isn't worth the effort if the code requires such drastic modifications.
- oelmekki 14y agoWait... dependency on querySelectorAll ? Weren't the point of javascript libraries to be crossbrowser ?
- nacs 14y agohttps://developer.mozilla.org/en/DOM/Document.querySelectorAll#Browser_compatibility https://developer.mozilla.org/en/DOM/Document.querySelectorA... Looks pretty "crossbrowser" to me. Seems to be supported on many mobile browsers too based on that link. The only possible issue I see here is IE < 8 but then again, I'm not sure I'd want to bother with IE6/7 support.
- mkmcdonald 14y ago"cross-browser" is a misnomer that seems to have been invented by DOM library authors as a marketing tool. If we're talking about the en vogue subset of browsers, then QSA has support. If we're talking about a set of browsers where a usable DOM implementation is provided (most dating back to Netscape), then, no, support is not provided. "Works in all browsers" should be closer to the latter, not the former.
- huskyr 14y agoI don't get it. The featureset on this project is so small that for anything else than a simple testpage it won't be good enough. And for a case like that, you can simply do vanilla DOM scripting yourself. If you want a library that's like jQuery but smaller simply use Zepto.
- ashconnor 14y ago"In short, Zepto is expected to work in every modern browser and browser-like environment, except for Internet Explorer." I can write off that idea then.
- huskyr 14y agoIf you want a library that both supports older and newer browsers you need jQuery. But you could load Zepto if the browser supports it, and otherwise load jQuery because their API is the same.
- mistercow 14y agoWhat I want is a jQuery-like library that can dynamically load alternative versions based on the browser in use, so that modern browsers load something close to zepto, while IE6 loads all the fixin's.
- huskyr 14y agoPut this in the end of your html file in a <script> tag (function() { var src = (document.querySelector) ? '//zeptojs.com/zepto.min.js' : '//ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js'; document.write('<script src="' + src + '"><\/script>'); })(); This will load Zepto if the browser supports it, and jQuery otherwise.
- astrodust 14y agoIt'd make everyone's life a lot easier if these selector methods were simply baked into the browser in a standardized way.