This article is intended for those who are prepared to write JavaScript frameworks or who have already written a little bit,
My idea of preparing for the framework was long ago. There are mainly the following reasons:
- For small applications, I think jquery is very good and there is no need to write the same framework as jquery. (Except when learning)
- But most of the time, I need a javascript framework with various small functions (for example, tab-flashing effect-pop-up window advertisement-text box Ctrl + enter event). For the website background, A complete UI framework is needed.
- I think the ideal UI framework should be:
- Nice interface (I'm satisfied with the interfaces of the ext dwzjs Framework)
- Object-oriented (EXT is my satisfaction) (for example, to create a panel, use the new panel (). Show () form)
- Simple and flexible (jqueryui Yui is my satisfaction) (for example, if I need a text box, I just need to introduce the text box, and it is very convenient to find the resources corresponding to a function)
- Free (EXT is not free) (at least lgpl Protocol)
- High speed,CodeSmall (this is required, and all frameworks try to achieve this goal)
- To meet the above conditions at the same time, I made a difficult decision to enter the Javascript framework development field.
At first, I spent some time writing code, but I knew it only after I wrote it.
The framework is not what you want to do, but what you want to do.
So I stopped and started to read the jquery mootools and ext source code.
After these source codes have been roughly completed, it is very important to start designing the framework-design.
I found that many people write frameworks to imitate the design of existing frameworks, rather than designing them themselves. Therefore, many people who claim to write the framework are actually only the shanzhai framework.
For example, I found that the structure of a domestic framework is similar to that of jquery, but some internal function names are completely the author's habit-and there are even many Syntax problems in English.
Some people write their own frameworks to complete jquery's functions: if you do not want to learn, it is to waste your youth.
My framework is designed to classify all functions using object-oriented thinking. For example, a function related to an array: makearray, as a member of the array class: array. Create (["AAA", "BBB"]); creates an array.
For an object-oriented JavaScript framework, you must solve the following problems:
Module mechanism-you must provide a mechanism to manage all JS files. In addition, the problem of mutual reference between modules must also be solved.
Class creation and inheritance-this is basic. Note that the code for creating a class that is popular on the Internet does not support reference objects for members.
Basic library functions-do not need too many functions. This is mainly for your own use. Do not add too many functions you do not need.
Never add object. Prototype. Try not to add function. Prototype
Dom operations-remember to be compatible, for example, in case $ is used
Dom operations are not perfect for most people. You must learn mature frameworks or directly use mature frameworks.
Ready document loading and running-this is required. We recommend that you learn jquery.
For specific solutions, see
At present, I think my underlying framework has been completed, and then the function is implemented. The implementation details are described below.
Most people should have never thought about how to do it before starting it. As a result, there are many problems, and they also feel that the code is messy. At this time, you have to review the code and cannot continue writing.
Qq 744257564 is good at front-end xcould. Welcome to discuss it.