Use jQuery to construct the javascript infrastructure

Source: Internet
Author: User

JQuery's use began to become the primary choice for javascript developers. However, without an overall plan, simple adoption will inevitably increase the maintenance cost in the future. A large number of jQuery plug-ins are like a double-edged sword, on the one hand, it greatly saves the development time and cycle, but also causes the load burden on WEB pages, resulting in a huge cost of protection and second-level extension. Therefore, before using the plug-in, a basic javascript architecture is required. The basic functional components can be clearly implemented and extended.

We think that jQuery is just a basic underlying tool set, encapsulating element selectors, events, and so on, basically meeting General Requirements, however, to improve the efficiency and reusability of javascript development, we need an overall layout. biuuu believes that the simplest idea is as follows:

1. encapsulate an operation on the existing ajax interface, which is mainly used to unify the ajax entry. At the same time, you can further segment the GET and POST operations to separate them, you can check the configuration, such as filtering parameters, checking parameters, and adding global parameters. The configuration is in one step and the reusability is very high. The implementation is as follows:

Var ajax = {get: function () {jQuery. get (url, [data], [callback], [type])} post: function () {jQuery. post (url, [data], [callback], [type])} 2. encapsulate a unified pop-up box, dialog box, and other interactive windows, interactive pop-up window operations are implemented through a unified interface, which saves development time and facilitates the adjustment and optimization of the overall style.

3. provides basic plug-in loading functions, which are similar to the factory mode and unified plug-in loading and calling portals. This facilitates later extension and maintenance, so you do not need to care about plug-in update and upgrade, you only need to call a unified interface.

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

From the above four points, the overall architecture is just a relatively low-level solution. In fact, there are security and performance considerations, but at least this idea is needed, the simpler the architecture, the more reasonable the architecture is. The javascript system is no exception. In actual use, through integration and optimization, it is as simple as improving javascript development efficiency and javascript capabilities.

Source: Must excellent blog Original: http://www.biuuu.com/p1295.html

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.