Dataviewjs script lead to slow response times while typing

What I’m trying to do

The goal is to have at the top of a note all open tasks which might be added somewhere in the same note.

Things I have tried

I use this dataviewjs script:

const query = `
not done
path includes ${dv.current().file.path}
# you can add any number of extra Tasks instructions, for example:
group by heading
`;

dv.paragraph('```tasks\n' + query + '\n```');

Which works, but if I type now in the note, especially if I add new checkboxes aka open tasks typing gets super slow because the dataview at the top of the note gets constantly updated.

Any idea how to achieve this in a more performant way? I would be even happy if the dataview doesn’t do live updates but only updates once when I load the note. The goal is, that if I come back to the note I directly see all open tasks accross the note. While I’m editing the note, I don’t need live updates of the list.

Any idea?

Hello.

Does a regular Dataview (non-JS) query cause the same lag?

```dataview
TASK
WHERE file.name = this.file.name
```
1 Like

I’ve mostly stopped using Dataview, but I used to put queries in folded callouts. That seemed to help with performance. It’s worth a try. YMMV.

e.g. using Hampton’s example:

> [!todo]-
> ```dataview
> TASK
> WHERE file.name = this.file.name
> ```
1 Like

Hi!

thanks @anon45210282, this seams to improve the performance. I will keep an eye on it during day-to-day work. Folding it away by default, like suggested fro @ariehen could be another option. Although I would prefer not to do it because it is a bit against the purpose of the open task list at the top, to avoid that I miss important tasks.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.