Skip to content
Advertisement

Another way of implementing an If else statement for viewport check?

I am dealing with a simple premise that questions viewport and based on that i am returning different aspectRatios. Now, for some reason i always have else return as true and then millisecond later the viewport gets validated. The result is that i am picking 2 aspect ratios and that makes me download additional image, which presents as unnecessary. I am wondering if there is a way around it, or to write it differently?

JavaScript

Advertisement

Answer

Check for viewport explicitely first

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement