Five Tips To Make CSS Super Fast and Effective
Posted By : Rajan Rawat | 08-May-2018
Did you ever think what is the size of your CSS of your site? If the CSS of your site is ballooning, there must be chances that it could be delaying the time of rendering the page
because CSS is the first file that every browser compile or discovers and it will block the page until your CSS is parsed and downloaded.
Here are some five important tips to make your CSS faster.
1. Use of shallow selector
every parent told their children that shallowness is not a virtue, but in the case of CSS, it is opposite. Always and consistently use the shallow selector it will you trim the kb of a large CSS file here are some given below:
nav ul li.nav-item
this could also be written as
.nav-item
2. Shorthand properties use
This is a very common thing and you will not surprised at how and why the longhand properties we use. I will show you some longhand properties which are given below.
font-size: 16px;
line-height: 12px;
font-family: "Arial", "Helvetica", sans-serif;
above code can be trimmed and tied up like this.
font: 16px/12 "Arial", "Helvetica", sans-serif;
The shorthand properties of font will condense the several declarations and it will convert into one line that takes less space.
3. Preload resource hint use
This is the first thing you have to do on your webpage because preload resource hint will tell your browser to your website
Or your server configuration as an HTTP header:
Link:; rel=preload; as=style
4. Cull redundancies with
It is ruby based toll
gem install csscss
after the installation of you can check your
csscss -v style.css
after this you will how much of space will be saved
5. Extra mile with
for
for installation write the below code.
npm i -g cssnano-cli
then for optimization use the below code
cssnano style.css optimized-style.css
after this you will see it will create gulp file and then run command gulp watch in
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Rajan Rawat
Rajan is a UI Developer, having good knowledge of HTML, CSS and javascript. His hobbies are internet surfing and watching sports.