javascript - stacking pages in SPA, good idea or bad? -
i've created framework in javascript personal single page applications, , i'm trying add stacking page feature it.
if have ever worked android, have seen every new activity or page created in android, pushes previous 1 in stack can accessed once user presses button, history in browser.
the difference in android page has been pushed stack, stays there until os runs out of ram or something, in browser page gets destroyed no matter what.
now, in framework, have come simple soloution keep pages in memory when user presses button, instead of loading data server, find page in stack , if exists, bring front , push current page stack.
but there issues method:
if keep stacked page in javascript variable or keep in dom , make display: none; style applied it, bringing front , make visible requires painting whole page again , if page large, means lot of process , makes transition between pages extremely slow, specially if have animation going on while page transition.
and if stacked page visible, , pushed using z-index, scrolling cause problem, scroll previous pages still available. , if make pages overflow: hidden; still if stack multiple pages, scrolling becomes slow , choppy because browser has scroll on multiple layers of painted pages.
and question is, idea stack pages these problems? or not meant happen in browsers yet?
depending on spa don't think idea keep pages in dom , hide them display: none;
or different z-index. try keep state / information of page in variable , remove related elements dom. when user going 1 page recreated elements information stored in variable. way prevent load information server , don't have problems going state.
you might able optimize further keeping last page in dom , hide , keep state of pages before in variable.
Comments
Post a Comment