Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
JQuery.ish - A Simpler jQuery (github.com/bshack)
22 points by jameswyse on May 12, 2012 | hide | past | favorite | 19 comments


I 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.


"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.


If 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.


What 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.


Put 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.


It 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.


"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?


I'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.


That feature set sounds like zepto, which comes in at 8.4K. If it supported IE9, it'd be pretty killer.


You could also use bits from the jeesh:

https://github.com/ender-js/jeesh


How about 400 Bytes?


Down! :)


It'd make everyone's life a lot easier if these selector methods were simply baked into the browser in a standardized way.


Can Google Closure Compiler compile an app with jQuery but only include parts of jQuery that the app depends on?


Yes, but not directly (jQuery is not written in a compatible way for dead code removal). Instead, use https://github.com/zgrossbart/jslim


This 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.


Wait... dependency on querySelectorAll ? Weren't the point of javascript libraries to be crossbrowser ?


"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.


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: