On one page, when loading it, you need to display: The data from the account that I receive via the API, which includes decoding the json file and uploading about 100 images to the page, so in addition you need to output about 4000 (!) Images to the same page and names from the database (mysql). And all this at once when loading the page!

When I go to this page under normal conditions (I simply removed the data from the database and simply decrypted json on the spot), then 10 seconds first the transition itself is loaded, and in another 20 seconds the page itself. On some sites, I saw how the transition happens instantly, and the data seems to be loaded gradually in its block. At the same time, this practically does not affect the loading of other elements on the page. Tell me please, what kind of magic is this and how to google it?

  • Apparently you need to get rid of json, if it is large, optimize queries to the database. What would HTML part of the page generated instantly. A picture to give NGINX and links to them on the page should be static, i.e. no sign ? in the URL (without calling scripts). And in addition, you can implement the creation of img elements on the page as you scroll (this is already on JS) - Mike

2 answers 2

This magic can be realized, for example, if you first load just the structure of the page without heavy data, for example, only the text data of the account. After that, when the page loads, you can load the rest with Ajax and insert them into the pre-prepared blocks.

When using jQuery, Ajax request to send inside:

  $(document).ready(function(){ // Ajax }); 

    If you just need to show the pictures as they are without further operation with them (for example - clicked - increased and so on ...), then make one of the pictures before displaying! I form about 7000 pictures in such a way - mini-sketches - in one picture, the processing time is 0.01-0.1 sec, the output to the screen is instant. Feel for the GD library, there are methods for all occasions. For reference, look at the output of miniatures on the booking-com - there are 20-50 mini-pictures to each hotel-hotel, etc. It goes like one long picture.