Top Banner
OPTIMIZING INFINITE SCROLL Paweł Sułkowski
9

Pilot Tech Talk #7 — Optimizing Infinite Scroll by Paweł Sułkowski

Apr 15, 2017

Download

Education

PILOT
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Pilot Tech Talk #7 — Optimizing Infinite Scroll by Paweł Sułkowski

OPTIMIZING INFINITE SCROLL

Paweł Sułkowski

Page 2: Pilot Tech Talk #7 — Optimizing Infinite Scroll by Paweł Sułkowski

Symptoms

Lost smoothness of the scroll

Page 3: Pilot Tech Talk #7 — Optimizing Infinite Scroll by Paweł Sułkowski

Problem

Large amount of elements in the DOM along with too many layout’s recalculations / re-paintings

More about what forces layout/reflow: gist.github.com/paulirish/5d52fb081b3570c81e3a

Page 4: Pilot Tech Talk #7 — Optimizing Infinite Scroll by Paweł Sułkowski

Solutions

Keep the DOM clean by removing redundant elements

or

Hide not visible elements to remove them from browser’s render-tree

Page 5: Pilot Tech Talk #7 — Optimizing Infinite Scroll by Paweł Sułkowski

Algorithm

Add an event handler to onscroll event and set „display: none” property to elements which are not

visible

Note If the dimension of an element is not known before rendering don’t forget about caching once you get it.

Page 6: Pilot Tech Talk #7 — Optimizing Infinite Scroll by Paweł Sułkowski
Page 7: Pilot Tech Talk #7 — Optimizing Infinite Scroll by Paweł Sułkowski

Algorithm (2)

Add an event handler to onscroll event and set „display: none” property to batch of elements which

are not visible

Note If the dimension of an element is not known before rendering don’t forget about caching once you get it.

Page 8: Pilot Tech Talk #7 — Optimizing Infinite Scroll by Paweł Sułkowski
Page 9: Pilot Tech Talk #7 — Optimizing Infinite Scroll by Paweł Sułkowski

Thanks