OptiFine may be used with the Fabric Mod Loader, just like Forge. Having said that, it is a little more difficult than Forge. This is because, in addition to OptiFine, you also need to download the OptiFabric Mod. After that, your mods folder will have both of these modules installed. By acting as a bridge, OptiFabric enables fabric compatibility with OptiFine. However, this will let you use fabric mods to play OptiFabric. Every feature, including shaders, works with fabric as well!