How to do it...
If you are using HTML (not HTML5 for now), try to always write this line of code:
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
Here, xmlns
is the XML namespace and it should always have the value as http://www.w3.org/1999/xhtml. You can define in which language it should be rendered by setting the value of the lang
attribute.
Put all the CSS files at the top under the head
tag and try to move down all JavaScript at the bottom of the HTML code. CSS is required at the top for two reasons:
- To have a presentational layout as it should be
- So that it can be downloaded in parallel along with other HTTP requests
Use the tableless design whenever possible. The tableless forms may not make the page load faster but it will surely enhance the speed due to the following reasons:
- Less number of DOM elements to be parsed
- Layout being taken care by CSS
- We can use the same CSS code for more tables if present, which would save a number of lines of code and would render faster
If you are good at CSS, converting HTML table elements into a CSS layout should be a cakewalk.
Check your W3C standard validity related to HTML, CSS (mainly), and load time on a regular basis.
We shouldn't leave back any error while writing tags. It should be properly closed and you should use proper tags for the specific purpose, for example, don't use the <b>
tag to make the string bold, rather use <strong>
. Use proper ending methods of one-sided tags, for example, <br />
instead of <br>
. It would not make the site faster but will make parsing faster without any error.
We should avoid using inline JavaScript as much as possible and you should put external JavaScript files at the bottom of the HTML code. Because while downloading JavaScript files, it doesn't allow downloading anything else that will make the page load slower.