Problem/Motivation
Toolbar using client-side session (localStorage) to store the toolbar state now. And this is default to render in horizontal mode. When users toggle to Vertical Mode, on each page load there's a jumping after page is fully loaded. Due to browsers limitations, frontend performance concern and Drupal's design (eg. Can't using inline scripting / Can't delay rendering after JS), we must pre-render CSS class for toolbar in backend.
About `horizontal mode` we fixing in #2542050: Toolbar implementation creates super annoying re-rendering.. (@see Comment #61, Code explained itself. )
More ref about browser side: http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/
** @droplet: noted that, there's nothing about Backbone performance or bad coding on JS side.
Proposed resolution
Possible Workarounds (by @droplet):
A: Using Backend session.
B: Delay rendering after Page is fully loaded. (BAD IDEA)
C: Adding Anime to make it looks more smooth. (Needs proof)
D: Drop `horizontal mode` for desktop users.
Remaining tasks
- TBA
User interface changes
- TBA
API changes
- TBA
Data model changes
- TBA
Comment | File | Size | Author |
---|---|---|---|
#14 | cookie-diff.patch | 3.65 KB | droplet |
#14 | full.patch | 15.51 KB | droplet |
Comments
Comment #2
DuaelFrIsn't it possible to just use a session setting? It seems overkill to store this little setting in the database.
Comment #3
droplet CreditAttribution: droplet commentedI think you refer to server side session settings right? It's also involved with DB so that works. Just we may have ONE jump at first time to visit the site
Comment #4
DuaelFrThat'd also be easier to store it in a cookie even if the EU regulations are nuts about that.
Cookies can be written in JS then read in PHP unlike session variables that can only be written and read by PHP.
Comment #5
ParisLiakos CreditAttribution: ParisLiakos commentedDefinitely session. Having it in session means it can be toggled without having to visit the settings form.
Even if its on horizontal mode every time someone logs in as default
Comment #6
DuaelFrHaving the setting in a session variable requires that clicking on the switcher triggers an AjaX call to a new endpoint that is going to set the value.
Having the setting in a cookie requires nothing else than writing the cookie with client side JS on click on the switcher.
Both requires about the same amount of code to read the value from its storage and output the right CSS class.
As a bonus, the cookie can be set as a cache context but the session variable cannot (afaik).
Comment #7
ParisLiakos CreditAttribution: ParisLiakos commentedTrue! Also implementation is easier.
So:
I think something like the above should be enough, and easy (why not merge it to #2542050: Toolbar implementation creates super annoying re-rendering. )
Comment #8
DuaelFrDo that class really have to be on the body?
I may be an issue for caching and performances.
Comment #9
droplet CreditAttribution: droplet commented@DuaelFr,
Umm.. For Vertical Mode, YES. Adding padding to left.
Comment #10
DuaelFrI asked on IRC for some cache experts to have a look at this issue.
Let's wait a bit for their opinion and refine the IS and the title now we have some more clear ideas. :)
Comment #11
Wim Leers+100 to
It's not at all clear why we want to do this in the first place. Please explain it in the IS.
On first glance, it's a very very bad idea for performance & scalability to store this on the server side (for every session or user). Even more so because it's already being saved on the client side. This can only be answered with more clarity if there is an actual issue summary.
Comment #12
droplet CreditAttribution: droplet commentedComment #13
droplet CreditAttribution: droplet commentedComment #14
droplet CreditAttribution: droplet commentedAttached a patch with state storage.
I would like to hear what you're concerned on the performance side.
eg. extra cookie ?
eg. no more full page caching in frontend for non-admin user ?
eg. can't proxying ?
** We should think in average site builders side. **
Comment #15
kostyashupenkoComment #17
Bcwald CreditAttribution: Bcwald commentedAnother reason this is important is because Safari private browsing mode on both iOS and OSx dont support SetItem, which causes ALL of the javascript on your site to break. AFAICT this is the only place in core that sets a variable with LS.
See my issue here: https://www.drupal.org/node/2711707
Comment #19
effulgentsia CreditAttribution: effulgentsia at Acquia commentedAdding #2711707: Use of LocalStorage setItem not supported in private browsing in safari, breaking all JS on the site. as a related issue per #17. In #2711707-7: Use of LocalStorage setItem not supported in private browsing in safari, breaking all JS on the site., I asked whether it makes sense to close that as a duplicate of this one.
Comment #27
nod_another approach without a cookie
Comment #28
droplet CreditAttribution: droplet commentedwow. I don't know the toolbar exists that long.
Note: EU law is about tracking, not has a cookie or not.