A
A
Andrey Andreev2015-09-27 18:51:59
JavaScript
Andrey Andreev, 2015-09-27 18:51:59

How to implement an analogue of lazyload lazy loading of content on jquery?

How to implement an analogue of lazyload lazy loading of content on jquery?
The essence of the idea: There is a landing page - long, with a bunch of pictures. It takes quite a long time to load. There is an idea to do something like lazyload, only that the content is loaded not on scroll, but simply sequentially. The first screen would load first, and then everything else. Thus, the actual download speed will not increase, but the user will be able to see the content of the first screen much faster.

I think this topic will be relevant because now wherever you click, you will get to the landing))

here is a link to an article on the topic:
habrahabr.ru/post/87083

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Ineshin, 2015-09-27
@maaaaaaan

There is no meaning at all. The real weight of the page is given only by pictures, everything else is usually general.

I
IceJOKER, 2015-09-27
@IceJOKER

The first thing that came to mind was to split the code into several pieces - 2.html, 3.html (or 1 php file) and create a function that will recursively load all blocks, i.e. Initially, the 1st piece of markup has already been loaded on the page and we request the 2nd with ajax, after loading we request the 3rd and so on.

var pieces_count = 4;
function orderedLoad(count){
  if(count > pieces_count) return;
  $.get(count + '.html', function(data){
     //проверяем и вставляем data
    orderedLoad(++count);
  });
}

orderedLoad(2); //со второго начинаем, т.к. 1й(основной) кусок лучше сразу же отобразить

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question