To install the sodium mod you will first need to install fabric. Using fabric instead of Optifine comes with many benefits. The main one is that performance on fabric when using performance improving mods will give you better FPS than Optifine. Fabric mods also update much faster than Optifine.
Explanation (You can skip the explanation if you don't care about it)
To summarise, think of Optifine as an all-in-one package while Fabric is barebones. By installing mods on Fabric it is no longer barebones and can become powerful. There are different mods that add different features, installing a mod called Sodium for example will improve your FPS drastically but if that's the only mod you have installed you still won't be able to use shaders. You need a mod called Iris which will allow you to use Shaders. These are both separate mods that add their own specific feature to fabric but by using them together you are able to reap the benefits of both mods. There are other mods that improve FPS such as Lithium and Starlight, by adding all of these mods together you get better performance than Optifine.
Go to https://fabricmc.net/use/ and click on the "Download for Windows" button.
Open the fabric-installer exe file you download and click on the "Install" button. In this tutorial I will be using 1.19.2
Now that you have fabric installed you need to install mods that improve your FPS and allow you to use shaders. To get to the minecraft mods folder go to your search bar and type: %appdata%. Click on the %appdata% folder.
This will open file explorer and you need to open the .minecraft folder
After you've opened the .minecraft folder you need to create a new folder and call it mods
The mods folder is where you will install the fabric mods.
Now that you know where to install fabric mods you just need to download them.
Here is a list of mods that I recommend:
Fabric API: https://www.curseforge.com/minecraft/mc-mods/fabric-api
Why do you need Fabric API? A lot of mods require this so you must download it.
Why do you need Sodium? Sodium is a mod that drastically improves performance, better than Optifine.
Why do you need Iris? Iris allows you to use shaders, even if you don't plan on installing shaders the option to have it may be useful.
Why do you need Starlight? Starlight improves performance by improving how lighting is calculated.
Why do you need Lithium? Lithium improves performance related to game physics, mob AI and block ticking.
Why do you need Farsight? Farsight allows you to view chunks outside of the view distance a server has set. This is very useful on creative mode servers.
Logical Zoom: https://www.curseforge.com/minecraft/mc-mods/logical-zoom
Why do you need logical zoom? This adds the zoom feature that Optifine has
Force close world loading screen: https://modrinth.com/mod/forcecloseworldloadingscreen/
Why do you need Force close world loading screen? 1.18.2 introduced a delay when switching to a different server/world, this mod removes the delay which makes things like cross server teleportation much faster.
Once you've downloaded the mods that you want, place them in the mods folder:
Open the minecraft launcher and make sure you've selected the fabric-loader profile that the installer created for you, then click play. That should be it, you have successfully installed Fabric! You can delete the fabric-installer exe file you downloaded because it is no longer needed.
How to update fabric when a new minecraft version is released:
When a new minecraft version is released you will need to download the fabric-installer exe file again from https://fabricmc.net/use/. When you open the file you can select the new minecraft version you are updating to.
How to update a mod:
It is important to update mods because they come with bug fixes. You also need to update all of your mods when a new minecraft version is released. A 1.17 mod for example will not work on 1.18 and you will need to get the updated version of the mod that supports 1.18. You can use https://www.curseforge.com/minecraft/mc-mods to search for mods and see whether they have updated to the latest minecraft version. In this example I'm going to show you the process of updating a mod. As you can see in the picture below, I have ferritecore-3.0.0.
In this example I want to check if there's an update for ferritecore and I can do so by going to https://www.curseforge.com/minecraft/mc-mods and searching for ferritecore:
Two results have come up, this is because there is a forge and fabric version of this mod. We don't care about the forge version since we are using fabric as our launcher so click on the fabric version of the mod as shown below
On the bottom right hand side you will see "Recent Files", I can see that the mod received a new update on Jul 2 2021 and the file is called "ferritecore-3.0.1". I currently have ferritecore-3.0.0 so I will download the new version.
Now that you have downloaded the updated ferritecore mod you can delete the old version and replace it with the newer version you just downloaded: