Answer the question
In order to leave comments, you need to log in
How to remove a block with a Yandex map for the mobile version of the site or postpone its loading?
There is a Yandex map on the site and it seriously affects the site loading speed. Is it possible to make sure that the map does not load at all at mobile screen resolutions, or is it somehow possible to postpone its loading?
Answer the question
In order to leave comments, you need to log in
It is better to postpone its loading on desktops until it enters the viewing area. Why overload? Maybe the user will not scroll to it. I'm not talking about the fact that you don't need to connect api on pages where there are no maps at all.
It is done elementarily. We follow the scrolling, at the right time we create a script tag through which the api will be loaded, insert it into the head, and upon its loading event, we start the map initialization. For greater beauty, let's color the empty div (in which the map will be rendered) in a gray color with the inscription "The map is loading ...".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question