Framework Classification and main function _javascript techniques of javascript frame design

Source: Internet
Author: User
Tags extend mootools

The current JavaScript framework can be divided into 5 categories, from internal architectures and concepts.

The first is a namespace-oriented class library or framework , if you create an array with the new array (), build an object with the new object (), the full Java style, so we keep adding objects and level Two object attributes to the object to organize the code. , such as pyramid-like, early Representative yui,ext (so, not dynamic companies are still using them)

The second is a class factory-oriented framework . Famous have prototype, also have MooTools, Base2, Ten, they basically except the most basic namespace, other modules are a class factory derived from class object. In particular, the mootools1.3 encapsulates all types into type types.

The third is a selector-oriented framework represented by jquery , the whole frame or library body is a special class array object, convenient to set operation (because the selector all of a sudden select the N element node), and then processed together. jquery has a couple of great things:

The "No new instantiation" technique, $ (expr), is to return an instance without requiring an explicit new one;
Get-all access rule;
Data caching system. This allows you to assign a node event.
Iife was also discovered.

The fourth type, the frame in which the loader is concatenated, has multiple JavaScript files, each of which is written in a fixed rule. Among them, the most famous is AMD. Modularity is a sign that JavaScript is moving toward industrialization, "the only way to write complex software is to have a clear interface and a combination of several modules, so that most problems only occur locally, and there is a desire to improve and optimize the local area without affecting the whole body. "Many enterprise internal frameworks are basically taking this framework, such as Dojo,yui,kissy,qwrap,mass, (REQUIREJS,SEAJS) and so on."

The fifth is the mv* with a clear layered architecture , first JavaScript MVC, (now called Canjs), Backbone.js and Spinejs, and then more in line with the actual MVVM framework of the front-end, such as knockout, Emberm,angular,avalon,winjs. In the MVVM framework, the original DOM operation is replaced by declarative binding, which is handled freely by the framework, and the user only concentrates on the business code.

The main features of the JavaScript framework

jquery Framework Class Library module division mainly based on the source code of the GitHub, basically a module of a JavaScript file, jquery began to focus on the DOM operation of the idea of the first is right, after the continuous compatibility, performance improvement, after years of development, jquery's huge plug-ins and perfect bug submission channels, making itself constantly perfect

The early kings of Prototype.js , which were divided into four parts.

Language extensions
Dom Extension
Ajax part
Obsolete part, new version implements original function in other ways

Prototype.js has a wide range of language extensions, including basic data types and "classes" borrowed from the language. Among them, enumerable is only a common method package, Objectrange, Periodicalexecuter, Templat is produced by class factory (from Community contribution).

MooTools Because of the elegant API design, its official website has a lot of high-quality plug-ins, not in the prototype expansion of the opposition to the decline in the wave.

Rightjs: Another framework on the prototype extension, mochikit a Python-style framework, very original, can go into the top ten frame.
Ten: Japan's famous blog Community Hatena JavaScript Framework, Amachang development, affected by Prototype.js, is the first space-named framework model;Mass framework: one with the goal of large module development, A jquery-style framework.

After a detailed comparison, we can easily draw the conclusion that the following framework features

Basic data operations are the basis, such as jquery provided by the trim CamelCase each map and other methods, prototype.js and other invasive frameworks on the prototype to add camelize and other methods to
determine the type of method, the common form is Jsxxx series
Selector, Domready Ajax is standard
for modern frameworks Dom operation is the most important, node traversal, style operation, attribute operation also belongs to its category now the
mainstream event System support event proxy
data caching and processing, the browser also supports the Data-property to operate, but not easy to use, need frame package
animation engine
the ease of development and extensibility of Plug-ins
provides solutions such as deferred that handle asynchrony
even if a class factory is not specifically provided, there should also be a method named extend or mixin to extend the object. jquery does not have a class factory, but it also has to add one in the jquery UI, which can be seen as important.
since jquery came out with a method called Noconflict, the emerging framework takes this approach in order to survive in a slit.
Many frameworks attach great importance to cookie operations.

The above mentioned is the entire content of this article, I hope you can enjoy.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.