lionleaf / dwitter

Social network for short js demos
https://www.dwitter.net
Apache License 2.0
769 stars 69 forks source link

Make feed less heavy #393

Open joeytwiddle opened 6 years ago

joeytwiddle commented 6 years ago

The feed is currently a big sluggish, I suspect because:

My suggestion:

lionleaf commented 6 years ago

Also see #66

This would be awesome to sort out!

How big impact does the actual creation of the iframe and canvas have? Currently it even does a network request, but I haven't had issues with the speed of loading new dweets, more with everything getting sluggish at some point.

So one alternative that might be simpler is to simply have a way to completely destroy iframes when scrolled away far enough and recreate them if they scroll back in.

But your idea to keep a pool of iframes that circulate is definitely going to be the fastest way to do it. It would require a change in how dweets are loaded, but doable with the json api and some js.

I would be happy with either solution as long as we can scroll infinitely!

sigvef commented 6 years ago

Some good ideas here! In particular though I think we're dependent on fully destroying and recreating canvases to make sure they are 100% clean slate. We can still unload iframes that have scrolled out of view!

yonatan commented 6 years ago

Have you considered play/pause buttons (i.e. no autoplay)?

imscary commented 6 years ago

play/pause buttons can be hard to create... In my opinion, autoplay is the best choice here

joeytwiddle commented 6 years ago

sigvef is probably correct. Reusing the iframe+canvas might work 99% of the time, but sometimes a dweet will change the window in a way we can't easily reset or undo. For example:

Unless we can solve all of those problems, we must destroy old iframes and create new ones. Still, I hope that doing just that should provide some performance improvement.

@yonatan Not autoplaying dweets would reduce resource consumption, but ideally I want to play them, I just want the resources back again once they are some way off screen! However, I would be quite happy with an option to disable autoplay (with autoplay on by default).

lionleaf commented 6 years ago

Full destruction and recreation is probably the way to go. I expect it would help quite a bit, so I suggest we start there. If the recreation is still slightly sluggish I expect we could do things like remembering the dweet code and create the new iframe + canvas purely by js, avoiding the network request. But that can wait until we have destruction / recreation in place.

@yonatan I agree with joeytwiddle and kipkat in that I want to keep the autoplay, at least by default. But I have considered pause/resume buttons, see #205, but I'm no longer certain if they are worth the screen estate