What I’m trying to do
I recently discovered the dv.view() function:
Complex function which allows for custom views. Will attempt to load a JavaScript file at the given path, passing it
dv
andinput
and allowing it to execute. This allows for you to re-use custom view code across multiple pages…
Currently, I re-use custom dataviewjs
code by including it in my note templates. This works fine as is, but dv.view()
has several clear advantages:
-
If I want to update the code, I only have to edit a single file. (In the past, I’ve used find and replace in VS Code, but this is more involved and less reliable.)
-
All of my notes would be shorter, cleaner, and take up less space.
However, I’m hesitant to use dv.view()
for a specific use case: navigation buttons at the top of the page (shown below).
If I include the code in a template, the buttons load simultaneously with the note. If, instead, I grab the code from another file with dv.view()
, the load time becomes more severe.
This may not seem like a big issue (and it wouldn’t be if it only affected elements further down the page), but it turns the once smooth experience of note-to-note navigation into a slow, unpleasant one (think Obsidian vs. Notion).
I’m wondering if there’s any way to speed up the load time of dv.view()
or if there is some alternative method that would accomplish the same goal.
Things I have tried
I have searched the forum, but there seems to be very little discussion on the topic. The dataview docs are helpful but brief.