D
D
danforth2016-09-12 13:07:38
JavaScript
danforth, 2016-09-12 13:07:38

AJAX + LazyLoad = brakes. How to decide?

Hello! There is an online store, there are filters on the category page, when you switch them, the content changes dynamically. At the same time, the unveil plugin is connected to the page, which loads pictures when scrolling. It so happened that when switching the filter, the page that was loaded was displayed with twists (GIF stub), i.e. Images didn't load on scroll. Fixed it like this:

<script>
    $('img').unveil();
        $(document).ajaxComplete(function(){
                $('img').unveil();
        });
</script>

That is, now, when the checkbox is switched to ajaxComplete, unveil() fires;
But a new problem has appeared, now when switching filters, the processor is very heavily loaded, especially if you poke through the filters notably and select several checkboxes: the page starts to hard to stupid. How can I solve the problem of high load on the PC? It is necessary either that the page loaded via AJAX already has the unveiling in the pictures, or that when the ajax request is fired, the old unveil() stack is cleared. Maybe I've screwed up crap now, unfortunately I understand JS so-so.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question