Hello peeps, I am Plxity and in today's blog, I'll be explaining a few super easy tips to improve performance score for your web application. ๐
Let's begin...
In case you are using google fonts for your webpage, add this piece of code in the head section. This will indicate our application that resources will be fetched from Google Fonts API in the future.
<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
Reference - Link
If you are using images, use CDN because it responds faster to images. You can check Cloudinary, It provides some amazing features to upload your images on CDN. Reference - Link
Use
loading
attribute with valuelazy
on images. It can be used to instruct the browser to defer the loading of images/iframes that are off-screen until the user scrolls near them.<img loading="lazy" href="Link to the image (Use CDN link for faster performnce)" alt="..."/>
Reference - Link
If you are using embedded Youtube videos in your application, use this trick for faster loading of your webpage and videos.
Minify your CSS and JS files for faster loading. Remove extra whitespaces and unused code. Various tools are available for implementing this. However, you can refer to this link by Google for recommended tools.
Use
defer
andasync
attribute in your<script/>
tag.Defer
attribute starts to download the script file in the background and starts executing once HTML is parsed.Async
attribute downloads the script file in the background and starts executing once is it downloaded completely. Use it as per the need in your project for faster loading. You can read more about these attributes here.Preload your CSS file. Preload tells the browser to fetch the resources because these will be used by the application very soon. You can
preload
images, videos, script file also. Example - How to preload CSS file.<link rel="preload" as="style" onload="this.rel = 'stylesheet'" href='style.css'>
Thank you for reading this blog. ๐ I hope you liked these tricks.
I'll keep updating this with more performance optimization tricks.