Lazy load dashboard cards
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 49.3k
- Forks
- 6.8k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 653
Description
**What problem will this feature request solve?**
When a dashboard tab loads, we immediately fire off queries for all the dashboard cards, even those that aren't visible in the viewport:
This puts unnecessary peak load on Metabase and customer databases, since we're loading possibly expensive queries that will never be seen by a human, all at once.
As an entirely unscientific test, we can compare loading either the whole dashboard, or just the first 3 cards.
This is the dashboard loaded as usual (running on my local machine, with a local H2 database):
This is the same dashboard, but only with the first 3 cards to simulate lazy loading:
After 30 refreshes, we can observe generally faster and less variable loading times. I would expect the difference to be greater with a remote Metabase and/or database:
**Describe the solution you'd like.**
Lazy load dashboard cards so that they're only loaded when they are in the viewport, or just outside of it. This should also work correctly with PDF exports.
Some users could argue this is a breaking change, depending on their workflow. Because of this, there should be a dashboard-level option which is disabled for existing dashboards, but enabled for new dashboards.
**How does this feature request impact you?**
It's difficult to gauge how much of a performance improvement this could be. It should make dashboards feel more snappy, and reduce the peak load on Metabase and customer databases. This especially helps customers using expensive databases, who will appreciate the cost saving.
One way to measure the potential impact would be to look at customer dashboard cards where the vertical grid position is at least ~16:
**Additional information**
https://metaboat.slack.com/archives/C05MPF0TM3L/p1773849739368819
Prior art: Grafana [introduced lazy loading in 2019](https://grafana.com/blog/a-closer-look-at-lazy-loading-grafana-dashboards/), with an [option to disable it per dashboard](https://github.com/grafana/grafana/issues/17257).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue identifies dashboard card loading and PDF exports as the relevant entry points, but names no files or tests. Start by tracing how dashboard cards are rendered and how exports request them. Done means cards load only near the viewport, PDF exports remain correct, and the dashboard-level default preserves existing behavior while enabling the feature for new dashboards.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- frontend, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100