October 19, 2017

Thursday, October 19, 2017
10 best practices for Front-End web developers
Front-end web development means the practice of producing HTML, CSS and JavaScript for a website so that a user can see and interact with them directly. The challenge associated with front end development is that the tools and techniques used to create the front end of a website change constantly and so the developer needs to constantly be aware of how the field is developing. Front-end web development can seem to be easy at first, but producing a clean, semantic, and cross-browser code is definitely a hard job. Here some hacks for Front-End web developers given below, read on:

10 best practices for Front-End web developers

1. Use CSS reset 
CSS Reset is a short, often minified set of CSS rules that resets the styling of all HTML elements to a consistent baseline. In case you didn't know, every browser has its own default 'user agent' stylesheet, that it uses to make unstyled websites appear more legible. Because by default, browsers don’t apply the same default styling to HTML elements, a CSS reset will ensure that all element have no particular style so you can define your own without the risk of many cross-browser rendering issue.

2. Don’t use @import 
CSS files can be included using the @import directive. This can be useful when, for example, you want to include a style sheet into another. While it works, the @import directive is much slower than the other way to include style sheets into a HTML document: It will not make a difference on low traffic websites, but if you have the chance to own a popular website, don’t waste your visitor’s time using @import.

3. Place JavaScript file at the bottom 
Popular practice of early web development was to place JavaScript files within the <head> and </head> tags. The problem is that your JavaScript files will be loaded first, and consequently your content will be loaded after. By placing JavaScript files at the bottom of your documents, you’ll ensure that JS files will be loaded only when the content has been properly displayed.

4. Use HTML semantically
HTML is a markup language, used to create structured documents by denoting structural semantics for text such as headings, paragraphs, lists, and more. If you started to create websites in the good old 90’s or in the beginning of the century, you know how dirty the markup was at the time. But happily, it has evolved. Among other things, it is important to use HTML element semantically.

5. Explain which DIV you’re closing  
Most of the time when we see website source, at the very bottom of the page, an almost endless list of closing </div> tags. Div's can be cleaners than tables, but without proper code organization, it can be as messy as table based code. Using indentation is a good start. But a tip that can definitely make you save lot of time is to comment every div tag you’re closing, like using <!-- end -->

6. Don’t write inline CSS
As a markup language, the right use of HTML is to organize documents by defining a header, a footer, lists, blockquotes. Some time ago, front-end web developers often used now deprecated HTML attributes to style a particular element. Nowadays, the style attribute allows developers to insert CSS directly into a HTML document. This is very useful for testing or when you’re in a hurry. But the <style> attribute is bad practice, even Google forbids it.

7. Don’t mix JavaScript with HTML  
Just like mixing HTML code with CSS is bad practice, you shouldn’t use any JavaScript in your HTML documents too. This may seems a bit harder at first, especially for beginners; but it is definitely not, and it will keep your HTML document clean.

8. Use conditional comments
IE sucks, and some clients suck even more by requiring you to create web pages which are compatible with this obsolete browser. To target specific versions of IE, you can use the well known IE hacks, as shown below:
height: 200px; /* normal browsers */
_height: 300px; /* IE6 */
.height: 250px; /* IE7 */
*height: 350px; /* All IEs */
Those hacks are extremely useful sometimes, but they are not the best way to target a specific version of IE, and it will cause your CSS validation to fail.

9. Optimizing images
Image optimization is an art that not many people master. There are many good image editing tools that allow us to get the best visual result for a certain file size but "under the hood" a lot more optimization can be done.

10. Test your site to avoid cross-browser issues
The term cross-browser is often confused with multi-browser. Multi-browser means something works with several web browsers. For your visitor's sake test and enhance your site make it as compatible as possible.

0 comments:

Post a Comment

 
Copyright © 2013-18 Crawlist All Right Reserved
Designed By Crawlist Team