Member-only story
7 Tricks to take the Performance of your Website to the Moon ππ
Are users complaining about your slow website? This article shares 7 tricks to take the performance of your website to the moon. Letβs get started!
1. Fetch only relevant resources
Did you know you can fetch only the CSS files relevant to the current device?
The link
tag has a media
attribute that can be used to specify the media query for which the stylesheet is intended.
<link
rel="stylesheet"
href="mobile.css"
media="screen and (max-width: 600px)"
/>
This will fetch the mobile.css
file only if the device width is less than 600px
.
A live demo of this can be found in w3schools.
2. Minify your code
Minification is the process of removing unnecessary or redundant data without affecting how a resource is processed by the browser. Minification can include the removal of code comments, white space, and unused code, as well as the shortening of variable and function names.