How to not load lottie on the Mobile View

I did put a display: none on the lottie animation, but on the background it’s still being loaded. How to stop lottie from loading on mobile devices because it makes the page slower on mobile.

You might have to use a bit of custom code