.js/.css fixes#1988
Merged
dscho merged 2 commits intogit:gh-pagesfrom Apr 3, 2025
Merged
Conversation
This file wants to use spaces only for indentation. However, by accident I introduced tab characters (oh my, am I glad that I do not have to get this reviewed on the Git mailing list) in 41436cc (application.js: allow for relative URLs, 2025-03-15). Let me fix that really quickly. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
When the JavaScript or CSS files are updated, caching rules often prevent the new versions from being picked up, whether due to browser-side caching or server-side caching. Let's avoid this by fingerprinting the files as described in https://gohugo.io/functions/resources/fingerprint/. We are technically not even interested in the cryptographic aspect of this, the only benefit we are looking for is that the file _names_ change in a predictable manner based on the file _contents_ (similar to how Git objects work...). While we are technically not interested in the cryptographic aspect, we can just as well benefit from it by adding the corresponding `integrity` attribute. However, we only do that if the base URL indicates that this will be accessed via HTTPS; Otherwise loading the pages locally via `file:///` would no longer work for those resources (see https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity for more information about this issue). Inspired-by: Toon Claes <toon@iotcl.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Collaborator
|
👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
.js/.cssfiles.Context
When new versions of the JavaScript and CSS files are deployed, for a while some users' browsers will still hold onto cached versions of them and the style or JavaScript-based functionality might still be messed up. Even if the browser caches do not have the stale files, the CDN still might have them.
To avoid running afoul of stale cached versions of these files, employ the simple-yet-effective method of using a filename suffix that is based on the file's contents. That way, there cannot be a stale cached copy of the file under the same filename.
While at it, fix the indentation of the JavaScript file which I had inadvertently made incorrect in #1980.