最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - JQuery source code - absolutely unreadable? - Stack Overflow

programmeradmin1浏览0评论

Is it just me or any JavaScript DOM manipulation or WEB UI Framework code is really hard to grasp because of long files, lack of proper indentation and scarcity of ments?

I have read couple good book on JavaScript and like the language, but when trying to understand the inner workings of all the popular frameworks I am having hard time to force myself to go beyond first hundred lines of a huge file.

This is a real question, not a statement. I am just trying to understand if I just suck or somebody else sharing my impressions.

Is it just me or any JavaScript DOM manipulation or WEB UI Framework code is really hard to grasp because of long files, lack of proper indentation and scarcity of ments?

I have read couple good book on JavaScript and like the language, but when trying to understand the inner workings of all the popular frameworks I am having hard time to force myself to go beyond first hundred lines of a huge file.

This is a real question, not a statement. I am just trying to understand if I just suck or somebody else sharing my impressions.

Share Improve this question edited Aug 16, 2011 at 16:58 SeanCannon 78k17 gold badges125 silver badges145 bronze badges asked Jul 30, 2011 at 20:49 LarikLarik 313 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 7

Oh boy. First, stop trying to reverse-engineer minified and obfuscated javaScript. Second, it's open-source and documented.

Who said he is reading minified code?

This question might be closed, but yes, jQuery has some rather unreadable source and bad organization. Organization in that John Resig thought it was a good idea to throw everything onto a single constructor and its prototype.

I guess if you want a DOM library that is well mented, try looking at Prototype. It's actually very overmented in my opinion, but if you want it as a reference for various DOM quirks and mechanics, it might be a good source.

The minified version is indeed not human-friendly, but it's smaller and faster. You're looking for the development version.

Whilst I can understand your frustration, jQuery (and other APIs, C++'s STL springs to mind) are not meant to be read by the average engineer. They are optimised for their purpose and excel at doing so, and that's why everybody uses them. Tried and tested.

Genarally jQuery uses a lot of closures and the notation of the framework as well as the plugins define a lot of anonymus functions on the go. So it's not easy "following" the way of the data through the code. At least that is my limited understanding. So if You just suck, You're definetely not the only one.

发布评论

评论列表(0)

  1. 暂无评论