Live data from Hacker News

Show HN: Minified.js – a fully-featured, 4K alternative to jQuery and MooTools

minifiedjs.com

71–80 of 145 posts

Re: Show HN: Minified.js – a fully-featured, 4K alternative to jQuery and MooTools

#71

The full, concatenated and uglified source of one-page JS web apps can easily run to >600kB. Whether my DOM manipulation library consumes 4kB of that or 35kB isn't especially important to me. I'm more concerned about features, cross browser support and familiarity other developers may, or may not have, with the API. I'll be happy to check this lib out though, the API and docs look nicely put together.

This is even more so if your site is served over HTTPS given the latency for the initial SSL handshake[1]. Even better not to load anything and have it properly cached on the client side.

If you do it right you don't even have the client send/receive an HTTP 304. For our app we have a lot of modular dependencies but we serve all of them from a unique prefix per build (eg. 'assets-SHA(build)/js/foo.js'). The second page load and beyond has zero requests for the same static asset. Whenever we have a new build of the app the unique prefix gets auto updated to force clients to use the latest versions.

For HTTPS make sure to mark your assets as public or they won't be cached:

    Cache-Control:max-age=31557600, public
[1]: http://www.semicomplete.com/blog/geekery/ssl-latency.html

Re: Show HN: Minified.js – a fully-featured, 4K alternative to jQuery and MooTools

#73
post #70

I see: tml xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:page="http://tjansen.de/minifiedPage" xmlns:i="http://tjansen.de/internal" xmlns="http://www.w3.org/1999/xhtml"> at the top of the page. Apparently the minification went too far. :)

No, that's the %^&%#! XSLT processor that keeps inserting unused namespaces.

Edit: oh, no, this time it was me unintentionally editing the compiled index.html.

Re: Show HN: Minified.js – a fully-featured, 4K alternative to jQuery and MooTools

#75

RyeJS is another alternative, though it focuses on speed, modularity and having an understandable source instead of size. Clocking at 6.2kb. http://ryejs.com/ (disclaimer: I'm one of the authors)

Focus on speed and modularity next to the clear code sounds interesting, but supporting IE 9+ only is kind of a bummer here, because it means "no" for XP users (I use XP64 on my desktop for instance) and there is still substantial number of them.

(And I do curse Microsoft for making IE 9 Vista+ only browser, which is quite likely explainable by use of some shiny new undocumented API, that wasn't available in XP and before. Microsoft and their browser tightly coupled with OS...)

Re: Show HN: Minified.js – a fully-featured, 4K alternative to jQuery and MooTools

#76

30KB distributed by a free CDN with a high chance that it's already cached in the browser VS 4KB that probably have to be served by myself. I am sorry, I probably would still go with the 30KB solution.

jQuery might be directly cached but does that really matter? You could make the browser cache Minified.js after the first loading. And I'm pretty sure it's faster to parse / run a 4KB script than a 30KB script.

Re: Show HN: Minified.js – a fully-featured, 4K alternative to jQuery and MooTools

#77
Nice one! i am digging it so far! Gonna try using it in one of my smaller projects to see how it goes.

btw anybody would like to use this in their Rails project, just drop https://github.com/tmlee/minifiedjs-rails into your app for asset pipeline. just did a quick one for that.

Re: Show HN: Minified.js – a fully-featured, 4K alternative to jQuery and MooTools

#79
post #72

What about event delegation? In JQuery there exists an overload to .on() that can pass a selector string to filter the descendants of the selected elements that trigger the event. Is there something similar in Minified?

No, not directly. From the jQuery API docs:

$("#dataTable tbody").on("click", "tr", function(event){ alert($(this).text()); });

In Minified, the easiest way to get exactly the same event handler is this: $("#dataTable tbody").each(function(tbody) { $('tr', tbody).on("click", function(){ alert($(this).text()); }, tbody);

Re: Show HN: Minified.js – a fully-featured, 4K alternative to jQuery and MooTools

#80
post #79
post #72

What about event delegation? In JQuery there exists an overload to .on() that can pass a selector string to filter the descendants of the selected elements that trigger the event. Is there something similar in Minified?

No, not directly. From the jQuery API docs: $("#dataTable tbody").on("click", "tr", function(event){ alert($(this).text()); }); In Minified, the easiest way to get exactly the same event handler is this: $("#dataTable tbody").each(function(tbody) { $('tr', tbody).on("click", function(){ alert($(this).text()); }, tbody);

That's not exactly the same at all.
Post reply on HN