-
-
Notifications
You must be signed in to change notification settings - Fork 124
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
Cache the CSS contents (in jQuery mode) #335
Comments
Thanks, @mossroy. The suggested code is in https://github.com/kiwix/kiwix-js/tree/Backport-CSSCache . In testing, it would be a good idea to use one of the "modern" ZIMs, I suggest |
I had a look at the code and tested on PC with Ray Charles archive (I could not test on my FirefoxOS device, and with the ZIM file you suggests, but will do later). I did not measure the performance, but it gives a real visual improvement : as the CSS is instantly loaded, the content "moves" much less after displaying the text. As there should not be a lot of CSS content in a ZIM file, I think it's not really necessary to put a size limit for this cache. Regarding the code itself, some variable/function naming look questionable, like newCC. But we can discuss that in the PR. I'll try to test more later. |
OK, thanks @mossroy. Just to be clear, I haven't put in any code to clear the cache anywhere except in Feel free also to change any of the variable names to anything more consistent. Then I can do a PR. |
I've refactored the code a bit and pushed on your branch. It's open to comments. The CSS cache indeed gives a huge speed gain! |
Great, that looks good! I'll do a PR. Memory issues: I believe this is probably the same thing that crashes xzdec.js on loading pages like Sine.html from Wikipedia. In this case it's not a mass of SVGs being sent to the decompressor, it's up to seven CSS files all trying to decompress at the same time. It causes a logjam, which is noticeable in a delay in the browser for opening the first page of the latest WikiMed ZIM. If you watch the console you'll see it takes an inordinate amount of time to decompress the CSS on the startup page -- this is somewhat masked in Firefox on the desktop because it seems to have better pipeline management, but it's pretty noticeable in Edge on the desktop, and in Firefox on an old / low memory device. Hence the huge speedup of caching. Solutions:
|
I understand. You did a very good job with @sharun-s at diagnosing this, and implementing a working workaround. |
Implemented with commit 8445238. |
Following the discussions in #130, this is about putting the CSS contents of a ZIM file in a cache.
@Jaifroid suggests to port/adapt the work of @sharun-s in kiwix-js, as it seems to be a very efficient optimization.
The text was updated successfully, but these errors were encountered: