V
V
Valentine2015-05-22 11:44:48
JavaScript
Valentine, 2015-05-22 11:44:48

API Yandex maps. How to do lazy loading?

Directory of companies with addresses, events on the map, etc.
The functionality needs to be implemented big.
Added Ya.Kartu - this monster-like garbage slows down the loading of pages, which is not good.
You need to implement loading on demand.
I don't want to wait for DNS to load their script.
How to do it? Download the script to the server?
And are there comfortable wraps or just hardcore? ))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Novikov, 2015-05-22
@Tpona

In theory, if you use API 2.1, everything is already optimized and loaded on demand. From documentation:

By default, all API components are loaded (load=package.full), however, in order to minimize the amount of traffic sent to the client application, you can specify a list of specific API entities that your application works with.
Note. package.full is optimized to load functionality when it is actually used, so in most cases there is no need to set the load parameter.
At first, the script itself (~ 32 kb.), And then 2 files (~ 300 kb.) were loaded. After the map is initialized, all other files are loaded. If you have the option to hide the map (put it in a block with display:none), only the first 3 files will be loaded, and the rest when the block becomes visible.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question