perf: batch DOM work, defer remote images, selective vault refresh#19
Open
davidvkimball wants to merge 3 commits into
Open
perf: batch DOM work, defer remote images, selective vault refresh#19davidvkimball wants to merge 3 commits into
davidvkimball wants to merge 3 commits into
Conversation
Add "Theme Aware Mode" setting that makes @DarkMode filter automatically adapt to Obsidian's current theme (light/dark). When enabled, images intelligently adjust filtering based on active theme. Features: - OFF by default for backward compatibility - Dark theme: inverts colors, removes dark backgrounds, boosts lightness - Light theme: keeps original colors, removes bright backgrounds, reduces lightness - Auto-reprocessing when theme changes - Theme-aware cache system (separate files per theme) Implementation: - Add theme detection via body.className (theme-light/theme-dark) - Add MutationObserver to watch for theme changes - Update DarkModeFilter with conditional logic based on theme parameter - Update ImageFilter interface with optional theme parameter - Update ImageCache to include theme in cache keys - Add setting toggle in plugin settings tab Modified files: - main.ts - theme detection, observer, setting - filters/ImageFilter.ts - add optional theme parameter - filters/DarkModeFilter.ts - theme-aware filtering logic - ImageCache.ts - theme-aware cache keys - README.md - documentation
- Debounce mutation batches and schedule work via requestIdleCallback - Skip heavy work when alt has no @; memoize filter parsing; dedupe in-flight work - Defer remote image processing until near viewport (IntersectionObserver) - On vault modify, only reprocess images tied to changed file paths - Bump version to 1.2.5
Owner
I have not noticed any performance issues with my plugin. Care to add a benchmark? Especially with the filter parsing cache... I doubt that exceeds even a millisecond per filter. |
Contributor
Author
|
Honestly this could be a false positive. For some reason I measured startup and it was wildly slow, but I can't get it to reproduce it so it must have been some one off incident. After I had made some tweaks it more performant, but don't have the stats with me. You can close this PR if you want. |
Owner
|
all good, thanks for trying to improve it ^^ i'll leave this PR open for now, maybe I'll find the time to review the code in the future :) |
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.
This vastly reduces startup time.