-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid flashing and slow page loading by inlining style sheets and widgets #800
base: gh-pages
Are you sure you want to change the base?
Conversation
I converted all of the HTML files to inline, by using a simple script. Also, this PR is a redo of #797, which had some issues. |
Thanks for the work, but the point of the system was that all of this content would not be duplicated. |
Sure, but I think the poor performance and jumpiness during loading is much worse than some amount of code duplication in this case. Do you have a suggested alternative that would achieve the same goals? I don't think it can be fixed with a runtime script It could be fixed with a dynamic serving system such as PHP, or a build step that concatenates resources. This is typically Also, see bjc-edc/bjc-r#45. @brianharvey commented on an earlier version of that PR (bjc-edc/bjc-r#491) that the user experience improvements are worth achieving (my paraphrase of course). |
Yes and I still think so. It'd be best if we can have our cake and eat it too, getting fast loading without having to edit every curriculum page when we want to change the formatting or something. |
Hi, friendly ping on this PR. Several points:
I could mitigate items 2 and 3 with one or more of the following approaches: A. Inline style sheets directly from If you are willing to at least accept inlining the style sheets into the If not, then at bare minimum I think these should be done:
What do you think? |
Hi Chris, Sorry I haven't had a chance to respond yet. I've got 4 courses and GitHub discussions are not really setup for something as intense as this. (3rd since PR comments aren't saved and get eaten...). I haven't taught CS10 in a very long time, though ostensibly I'm the one to still keep some of this running. But I will be in the Fall or Spring and I hope there's a good chance to make more significant changes then, too. Well, not in the middle of the semester, ideally. But also, I do not think this is urgent. It hasn't been dealt with because, well, there's been 500 other things that have been a priority.
In this case a single loading entry was basically the design goal ~7 years ago when this was created. Maybe it's a misguided goal, but I don't think code duplication is the answer. There are not that many updates that happen now and already there's a conflict. The flash annoying, but it has always been annoying. It's good to know that the loader still works even when you don't include the necessary parts, though I think it's somewhat confusing then since you'd get into a 50/50 state. But I think this is something to consider. That said, the loader itself is due to be burned in a fire, so I'm not defending it as a piece of engineering. As far as general approaches, there are two that aren't mentioned -- one of these is likely what we'd choose if we were starting from scratch today. These two are not really mutually exclusive, but in terms of really avoiding FOUC only one is needed.
Essentially, turn loader.js and the site into a basic SPA.
I don't mind the low opacity idea, but I think it would need to communicate "loading..." somehow to not feel broken. But certainly a possibility. That said, Chris: I do want to accept your contributions. It's just hard to have two PRs that are massive to content with. I realize you can't possibly have all the context for the history of how decisions were made, but it's pretty clear from the code that a single entry point was the goal. GitHub doesn't help with hundreds of files changed, so some guide to reviewing would be helpful. Plus, assuming you wrote a script to update all the content, it would be really helpful to include that. (Since it's a good check over missing content, and we'll probably need to use it in the future if we go down this approach.) |
Hi @chrishtr It's been a couple of months -- do you have any interest in working on this? Does a turbolinks / pjax style approach seem reasonable? I guess, in any system updates, reducing the async nature of loader would be good. Perhaps what'd make sense:
There are definitely some dependencies in the JS files, so it might be something to be aware of, but I think it's all solvable. |
Hi, yes I am still interested. Since you were busy with the end of semester I held off for a bit, and then my own work overwhelmed me for a while.
I could potentially try that. But it means an extra round trip for each page load right?
B and C will help, but there will still be some amount of ugly flashing... Re Jekyll, etc: I wonder if a simple build system would be good enough. I've been working with a (very simple) one on another project and it turned out to be not that hard. Let me see if I can make it work.
SG, some fun followup opportunities...! |
No worries! :) Also happy to google meet / zoom if it's helpful, and/or even an office. (It's kind of weird to say that!)
It's really only a 2nd page load solution, so we'd still want to do some tidying of the rest of the content loading, but in theory it should help.
I guess I'm in the minority here, but I don't think I'd mind a single flash compared to something like a full page spinner / delay all content until ready type approach (e.g. what many SPAs do...). Partially because if all hell breaks loose, at least the html that's presented is still readable. I am definitely constantly warming up to the idea of including some CSS in the initial page load. I do think it should be a fairly minimal set though (especially since libs like Katex and pygments are decently sized and not used everywhere).
Neat! I am a little weary of bespoke systems since you can end of with a maintenance burden...which I guess is lately what happened with a lot of the code here... |
Also see #822 . |
Currently, bjc-r pages are very slow to load and have a lot of flashing-of-unstyled-content. This is because all of the
stylesheets, as well as some HTML content, is dynamically inserted by loader.js. Browsers will then do this:
Load initial HTML, and kick off request for loader.js
Render what they have (unstyled content, because there are no style sheets
loader.js loads and executes, which inserts styles sheets and widgets on the homepage
Browser kicks off requests for style sheets, and renders what it has (now with widgets, but still unstyled)
Style sheets load and the page renders its final, correct version
All of this can be avoided with a very simple edit - simply inline the style sheets and widgets in the page.
I've also made some tiny edits to llab so that it is forward-compatible with inlining. It was already compatible with it in most cases.