Home > Web Front-end > JS Tutorial > JavaScript basic system based on jQuery architecture_jquery

JavaScript basic system based on jQuery architecture_jquery

WBOY
Release: 2016-05-16 18:12:51
Original
1068 people have browsed it

The use of jQuery has begun to become the main product of choice for JavaScript developers. However, without an overall plan, simple adoption will inevitably lead to an increase in later maintenance costs. A large number of jQuery plug-ins are like a double-edged sword. On the one hand, they save a lot of money. It reduces the development time and cycle, but it also causes the burden of WEB page loading, which will cause difficulty in maintenance and secondary expansion costs. Therefore, before using it, you need a most basic JavaScript architecture system that can clearly understand the basic functional components. , plug-in components are effectively implemented and extended.

We think that after all, jQuery is just a basic and lowest-level toolset, encapsulating element selectors, events, etc., which can basically meet general needs, but it must be viewed from the perspective of the overall WEB , in order to improve the efficiency and reusability of JavaScript development, an overall layout is needed. Biuuu believes that the simplest idea is as follows:

1. Encapsulate a layer of operations on top of the existing ajax interface. It is mainly used to unify the ajax entrance. At the same time, it can be subdivided to separate GET and POST. Through the global entrance, you can check the organization, such as filtering parameters, checking parameters, adding global parameters, etc., in one step, you can The reusability is very high, the implementation is as follows:

Copy code The code is as follows:

var ajax = {
get : function(){
jQuery.get(url, [data], [callback], [type])
}
post : function(){
jQuery. post(url, [data], [callback], [type])
}
}

2, encapsulates unified pop-up boxes, dialog boxes and other interactive windows through a unified interface Realizes the interaction of pop-up window operations, saves development time, and is conducive to the adjustment and optimization of the overall style.

3. Provides a basic plug-in loading function, which is similar to the factory mode. It unifies the entry point for plug-in loading and calling, and facilitates later expansion and maintenance. In this way, you don’t need to worry about plug-in updates and upgrades. You only need to Call a unified interface.

4 is actually some of the most basic and commonly used functions. This is related to specific projects and serves as a global tool class.

From the above four points, the overall architectural idea is only a relatively shallow solution. In fact, there are also considerations such as security and performance, but at least there needs to be ideas in this regard, the simpler it is The more it reflects the rationality of the architecture, the javascript system is no exception. In the actual use process, through integration and optimization, it is so simple to improve javascript development efficiency and enhance javascript capabilities.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template