Basic Coding Standards

I came across lot of front-end developers asking “What are the basic coding standards for front-end development?” Well, honestly everyone have their own way of writing codes, the way they are comfortable. But, if you ask me we should follow a practice of coding that all the developers understand and also, saves their time.

Few points that I follow are most important while coding:

  1. Code Indentation – The code should be properly indented with tabs and spaces. The hierarchy should be in such a way that by looking it we as a developer easily understand the structure. Also, it avoids missing any tags to close.
  2. Comments  A lot of developers do not comment or else they comment a lot, comment tells yourself and another developer what is your code about and why is it there in the first place. Second a lot of comments increases the file size and which also leads to slow down the website.
  3. Nomenclature – This is a very crucial and one of the most important factor of coding standard, when writing HTMLs we often us classes and now here’s the issue “What should I use for classes? Hyphens(-)? CamelCase?” Again, CamelCase is apt for javascript/jQuery but, for CSS it is recommended to use hyphens because while typing you need not hit shift key again and again for capital letters in between which increase your chances of making mistakes. People say using hyphens increases the size of css well, so does a capital letter so its recommended to avoid hitting special keys and save time. Using names of classes related to div is important. If its a container we better name it as container instead main-container or main-section. Using smaller names increases the speed of coding and reduces the code length.
  4. Project Structure – Well it goes as follows:
    1. Project Name (Folder)
      1. img (Folder)
      2. fonts (Folder)
      3. js (Folder)
      4. css (Folder)
      5. index.html (Files)
  5. Image Sizes – To avoid large images in website few tips, choose .jpg images over png if background transparency isn’t an issue. Saving it with quality of 50% or Medium also helps in reducing the files size. It is recommended that we convert icons to fonts (https://icomoon.io/app/) for fast loading and optimization.
  6.  Minify – Once all the code is tested its a best practice to minify all the css and combine them in one which reduces the server calls. Same applies to javascript/jQuery post development multiple js files can be combined, minified and hosted. If possible we can minify HTMLs too.
  7. Backup – Backup has always been an issue but, its never an issue if we start our projects after creating a repository on git. I usually use https://gitlab.com/ and https://www.sourcetreeapp.com/

 

So, these are points that we all should follow while we code as a front-end developer.

Leave a comment for any queries or requests.

Previous

Why Hello world?

Next

How to add custom post type to wordpress?

2 Comments

  1. You could certainly see your enthusiasm within the work you
    write. The world hopes for more passionate writers such as you who are not afraid to mention how
    they believe. All the time follow your heart. http://follr.me/JimGriffin/about

Comments are closed.

Powered by DisenoBox