Im adding functionality to a woocommerce site with over 20k products. On their archive / category pages, they are running an “infinite load” plugin. all it does is load the next set of products when they click the “Load More” button. This is very plain code, it binds an onclick to run ajax GET with the target of the next page. Once it gets a response, it traverses through it until it find the element node that houses the next batch of products. These then get appended to the dom.
Their request is for me automatically load the next bath of products when the client is scrolling through the loaded batch. plus bunch of additional little details.
I can simply trigger that button when the page is scrolled after a certain position, but I believe that this is kind of inefficient because we are requesting the whole next page every time.
I understand that this is just a http response, and that no scripts, images, etc.. have been processed / loaded; however, it bothers me that every time we send the request, we are going though lots of php logic and mysql queries that have nothing to do with getting the next batch of products ( IE wordpress options, load the whole wordpress framework, load pluggins, etc.. )
After reviewing the way the theme is built / woocommerce. I come to notice that there isn’t much flexibility. to load the archive page, the templating system searches for “archive-product.php”, which forces the get_header(), get_footer() function to run, plus all the hooked actions that have nothing to do with the batch of products.
I’m thinking to send additional parameters on the ajax request. When loading archive-products.php, i will check for these and bypass most sections.
DOWNSIDE: maintaining / updating this site on the future, will become troublesome. There are also lots of actions that are hooked to wp_head, which only runs inside get_header)()…
M I overthinking this??, should I just request the whole page and just pluck the sections I need? or is there another method that will be easy to maintain on the future.
- Hiện tại chúng tôi có hơn 25 nghìn bài văn mẫu các thể loại.
- Kho tài liệu, đề thi học sinh giỏi các lớp vô cùng phong phú.
- Mỗi ngày cập nhật hơn 100 đề thi chất lượng từ các website bán tài liệu lớn.
Tải đề thi VIP với giá siêu rẻ tại Vip.Dethihsg247.Com