UI: Flickering when loading themes on pages with long loading times #94706
Labels
No Label
legacy project
Infrastructure: Blender Web Assets
legacy project
Infrastructure: Websites
Priority
High
Priority
Low
Priority
Normal
Status
Archived
Status
Resolved
Type
Design
Type
Report
Type
To Do
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: infrastructure/web-assets#94706
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
There is a flicker in loading the theme that is quite noticeable on pages heavy on images, like Speakers, Attendees, or Schedule.
This is not just a problem of our implementation but something many run into when introducing themes.
Some propose using a bit of inline Javascript (vanilla) in the
<head>
, before anything, which is probably the best. Outlined in this StackExchange answer or this GitHub comment.Originally posted by @pablovazquez in infrastructure/conference-website#103972 (comment)
To prevent fickering, a theme initialization JavaScript snippet (and its minified version) has been created and added to development utilities, that can be included in project templates'
<head>
as inline JS. The detailed usage instructions have been added to Web Assets wiki page section on Enabling themes as well.The snippet initializes themes before the DOM has been loaded, and works like this in a nutshell:
dataTheme
item in the localStorage.dataTheme
is set, it assigns the accordingdata-theme
attribute to the<html>
tag.data-theme
attribute is already present while loading the styles, the page colours are correctly rendered from start.The solution has been tested locally with throttling simulating slow networks, and seems to work reliably.
@pablovazquez ⌃