Arranging the styles and scripts in a particular order is one way to improve the page loading speed.
It is recommended to keep the style sheets at the top and scripts after them. This is because when browser renders your webpage it first gets the HTML and then comes the CSS, JS, images etc.
The only solution to reduce the wasted time is to remove the patterns that makes the browser to serialize the download of resources.
How to optimize the order of your styles and scripts?
This is the simplest method. Here you just need to make a few changes in the HTML of your webpage. Styles and scripts are placed in the head section of the HTML. Here is the correct order to follow:
css code should be here
By keeping the files in this order will result in rapid increase of speed.
Applying Filters to Optimize the script and style order.
Filters such as 'Move CSS Above Scripts' makes sure that scripts do not halt the process of CSS resources loading.
By using the Apache Server, one enable the file by adding below code in the configuration file.
Use a Wordpress Plugin
Activating a plugin in Wordpress is the easiest thing one can do. Autoptimize plugin is a multitasking plugin, whereby it can perform the following functions:
- Concatenate, Minify and Cache the styles and scripts file
- Adds CSS direct into the header
- Minify HTML
If the plugin you use dynamically adds JS and CSS you should change it to page caching. Parallely to the Autoptimize you can also use the Cache Enabler, HyperCache, WPSuper Cache, and Comet Cache.
If website performance matters to you, then consider opting one of the ways mentioned in the article. This is the easiest way to get fast running website.