Front-end specifications

Source: Internet
Author: User

Front-end specifications

A well-regulated code is easy to modify and understand, so the following is a summary, hoping to avoid detours;

Basic Content, Please bypass ......................

1. Naming rules

 Naming must be meaningful. After all, writing the code down is not for you. In css, write the parent element in front to regulate it. Do not be lazy.

2. Please do not write native for a while and jquery for a while

 Many people think that I can't write a function, but the page is messy. If it is because you are not skilled, this is an opportunity to become proficient.

3. indentation

Although many editors have made indentation perfect, there will still be a gap between two spaces. In this case, do not be lazy. This space is like an ant on the ground. Hurry and clean it.

4. Tag Closure

 Although in HTML5, tags do not need to be closed, but for the sake of standardization, but also for the sake of better code to avoid some errors, I suggest you close tags

5. After writing the code, delete unnecessary comments, spaces, and empty tags.

 Many people add comments for the next modification, or modify the code. They will not delete the original one just in case, but have forgotten to comment it later, at this time, after writing the code, check it again and delete unnecessary ones so that you can better read the code.

6. logic problems

 I can only tell you this question: when setting up a page, use your brains and properly standardize the structure, as well as js. Please keep the logic smooth, reverse Thinking will make people watching your code go viral

7. Do not write px after 0

 Prompt in webstorm, do not burden the code

8. Pay attention to space issues

 

When you encounter the above structure, write it in one line. Otherwise, you will suddenly find that the browser has some spaces.

9. js obtains page elements,

In JQuery, if this element is used only once, do not define that the variable occupies the memory.

10. Add at the end;

Add at the end of js and css statements; it is not easy to make mistakes when compressing code

 

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.