Michael Naumov30k downloadsStore backlink cache to speed up `app.metadataCache.getBacklinksForFile`.
Asking Obsidian which notes link to this one means scanning every note in the vault. On a large vault that is slow enough to be felt — the Backlinks pane lags, and every plugin that needs backlinks pays the same cost, repeatedly.
This plugin keeps a backlink index and answers from it instead. The Backlinks pane gets faster, and so does anything else that asks. On a small vault you will not notice; that is the point at which you do not need it.
The documentation is an interactive demo vault. Every feature has a note that explains what it does and why you would want it, with buttons that measure the difference for real.
Start reading here — it is plain markdown, so it works on GitHub with nothing installed.
A copy of the vault ships with every release. You can access it via any of the following:
backlink-cache-demo-vault.zip from the Releases. It unzips into a single backlink-cache-demo-vault-<version> folder.demo-vault/ in this repository.getCache(), which Obsidian leaves empty for canvases. 03 Canvas backlinksFrontmatter Markdown Links plugin is installed. 03 Canvas backlinksThis plugin replaces app.metadataCache.getBacklinksForFile() with a faster implementation, adds an overload accepting a vault path as well as a TFile, and keeps the original reachable:
const fast = app.metadataCache.getBacklinksForFile(pathOrFile);
const safe = await app.metadataCache.getBacklinksForFile.safe(pathOrFile);
const original = app.metadataCache.getBacklinksForFile.originalFn(file);
To use the updated signatures from your own plugin, copy types.d.ts into your code. 02 Fast, safe, and original backlinks runs all three side by side.
The plugin is available in the official Community Plugins repository.
To install the latest beta release of this plugin (regardless if it is available in the official Community Plugins repository or not), follow these steps:
Add plugin button once and wait a few seconds for the plugin to install.By default, debug messages for this plugin are hidden.
To show them, run the following command:
window.DEBUG.enable('backlink-cache');
For more details, refer to the documentation.
All notable changes to this project will be documented in the CHANGELOG.
Contributions are welcome — see CONTRIBUTING to get set up.
See my other Obsidian resources.