There are many ways to improve WordPress performance. But here I would introduce a trick to dramatically improve the page loading speed.
Convert to html page
As a web page the ultimate content is html code. If we could response in html directly without bothering the server code and database to run the page would be loaded really quick.
- make sure the web page working as expected
- use browser developer tool to view the source
- copy the html source code
- go to File Manager of the CPanel, manually create folders and index.html file according to the url pathFor example: for url "https://hostlike.com/zh/web-hosting/"create folder /zh/web-hosting/, then create file index.html under the new folder
- open index.html with file editor
- paste the copied content to the index.html file
- save the content.
Dynamic content trick
If there is dynamic content, e.g. shopping cart item number. We can use JavaScript to update the value.
Add the following JavaScript code to the end of index.html content.
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
}
var cart_count = getCookie('woocommerce_items_in_cart');
$('.wcmenucart-details').text(cart_count);
Comments
This approach will change dynamic content into static, therefore, it is not for every situation. It is good for those pages witch contents are not changed often.
What’s up, after reading this awesome post i am as well delighted to
share my experience here with friends.