Minified files
Minified HTML5, CSS3 and Javascript files can save upto 50% of your memory space. So, it is necessary to minify files for faster loading of web pages
In this tutorial, we will see some of the important steps to minify the files.
- Avoid comments
- Avoid indentations
- As javascript does not require line-ending tokens, do not use semi colons for .js files
- Keep variable names as small as possible
- Declare all variables with their initial values in one line
- Avoid unneccessary whitespaces
- Instead of border:none use border:0
- Instead margin:0px use margin:0
- Instead of padding:0px use padding:0
- Try to create generic class for a set of sub classes which have common properties and values
- Try to use shorthand properties as far as possible
For example, instead of
typediv { margin-top:10px; margin-bottom:15px; margin-left:20px; margin-right:25px; }
div { margin:10px 25px 15px 20px}
- Try to write multiple selectors and their properties in the same line
- Try to add a constructor which contains the initial state of variable used in the programme
- Try to use short cut colour codes. For example, instead of writing #ffffff use #fff
- Try to find out for common properties and their values for different selectors into one comma-separated list of items
- Use image sprites and with the help of background-position properties we can crop and image and use that part of the image which is required
- To set colour and opacity use the functions rgba instead of using the opacity property
- If you want to implement a particular set of style to the webpage use the a class attribute for those HTML element
- If your right and left margin for HTML element are equal and top and bottom margins are also equal then use the shorthand property like margin {margin:10px 20px} This will set top and bottom margin to 10px and left and right margin to 20px
- Use the background image instead of the image element
- Use small size compressed images and audio and video elements
- Use AJAX(Asynchronous JavaScript and XML) to load of specific part of a page that is required to be updated instead of reloading the whole page
- our HTML element can be positioned in absolute or static type then use position absolute
- To save the size use an overlayn of object. This can be done through many ways like using Z-index property or carousels
- Before you want to give information on the home page of the webside but it is too large then use the marquee tag on the top or at the bottom
Comments
Post a Comment