Several Rules for writing Js Code

Source: Internet
Author: User

1. Do not use document. write () in large quantities ()

2. Check the client's ability to support objects (progressive) instead of checking its clients, and test the objects to be used.

3. Access existing HTML content instead of adding HTML through Js (separation of behavior layer and structure layer)

4. Do not use a proprietary DOM object (such as document. all of IE)

5. Put the script into A. js file instead of being visible everywhere in HTML.

6. improve websites that run well without client programming, instead of adding scripts first and then adding alternative solutions for non-scripts.

7. Keep the code independent. Do not use global variables that may conflict with other scripts. (Number of available objects)

8. comment out the code function, because you may maintain the code yourself in the future.

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.