yes query selector in this context will be more performant than getElement
refresh at 60fps + the iteration on 30x30 array
Christopher McCormack
@cmccormack
but using getElementsByClassName could you not eliminate at least one of the loops?
given I didn't review the code closely
Adel
@AdelMahjoub
we could yes
but I want the two method in the same context inside an iteration
Christopher McCormack
@cmccormack
grid = JSON.parse(JSON.stringify(nextGrid)); this is also very slow
I mean, relatively anyhow
Adel
@AdelMahjoub
that's actually surprising, but it is very fast
faster than spread operator
maybe because the implementation in chromium is fast idk
Christopher McCormack
@cmccormack
oops was I doing that on your project?
I'm sorry!
it's really fast now though
Adel
@AdelMahjoub
wow, amazing @cmccormack
that spread operator on a HTMLCollection !!
never thought about it :laughing:
Christopher McCormack
@cmccormack
probably not the fastest but I think it looks clean in code hehe
Adel
@AdelMahjoub
it is faster than earlier
Christopher McCormack
@cmccormack
sorry for editing your project though I thought it would only change for me
Adel
@AdelMahjoub
I invited you to edit, no problem , that was the purpose
Christopher McCormack
@cmccormack
glad I didn't delete a bunch of code then!
Adel
@AdelMahjoub
No I'm convinced that it is faster :laughing:
Christopher McCormack
@cmccormack
doesn't classList have a toggle method?
_
Adel
@AdelMahjoub
thats jQuery I think
idk when it was added , it seems clasList has a toggle method
Christopher McCormack
@cmccormack
yeah that api is pretty good
I think to use it in this context you would only want a single class though, maybe the default for a cell is whatever style you have for dead, then cell_live would change it
Adel
@AdelMahjoub
@cmccormack well I learned a lot, thank you
Christopher McCormack
@cmccormack
np
this stuff is always fun!
if @ezioda004 hadn't fallen asleep he could probably improve performance a bit more
Adel
@AdelMahjoub
usually I would use canvases for this stuff, but making it fast on the dom is good to try
Christopher McCormack
@cmccormack
I think it's pretty dang fast with just HTML haha
but I agree
I would probably change mine to canvas had I planned it from the beginning, mine isn't very performant
it would be if it didn't need click handlers I think
Adel
@AdelMahjoub
I made a lot of different versions, vue, angular, react all using dom and canvases, this one is one of a lot
it can be even faster using webgl with phaser
or pixijs
but yeah, one is a video game framework the latter is a rendering library so :laughing:
Adel
@AdelMahjoub
the good thing , it is possible to create git braches from glitch, now it is merged, I guess it will be useful for future ref
Christopher McCormack
@cmccormack
didn't know you could make branches that's neat
Adel
@AdelMahjoub
yeah, it is very different from what is was, very good work