Hacker News new | ask | show | jobs
by mkmcdonald 5105 days ago
What the jQuery team either perceives or peddles as "modules" are simply split files; there's no encapsulation. All that's new is a shiny node.js builder.

I am interested, though, that the team has finally noticed that optional code should be the norm. Resig himself has been quoted as wanting nothing to do with it[0].

However, omitting every single "module" only truncates 2484 lines, which leaves the 1.8.1b source at a staggering 6763 lines of code. There is still a great deal of work to be done before "modular" is a fair term to apply to the API.

[0]: http://i.imgur.com/Ta223.png

2 comments

There has been recent work to make jquery compatible with Google closure's advanced compilation[1]. As mentioned in John Resig's reddit comment you referenced, this would allow the compiler to automatically remove unused components in jquery and perform whole program optimizations. Unfortunately, this approach requires large rewrites to jquery to conform to the strict conventions required by the closure compiler.

[1] https://groups.google.com/forum/#!topic/jquery-bugs-team/2zb...

If we remove the blank lines and comments, would the line count be less staggering? By that measure we definitely shouldn't include Closure Compiler annotation comments since they add lines. For better or worse, we've focused on min-gzip size as a measure.

JavaScript doesn't have a formal notion of a module. What we're referring to here is the ability to exclude some chunk of functionality from jQuery and know that, internally, jQuery does not require it. We cannot know whether other code on the page requires it.

> optional code should be the norm

Is there an easy way to know what is "optional" code when including third-party plugins, short of analyzing all the code in advance? That's what Closure Compiler AO does, but it is not for the weak.

> There is still a great deal of work to be done before "modular" is a fair term to apply to the API.

If you've got some ideas we're open to suggestions.