Skip to content

Lazy load bottom tabs#202

Merged
jayohms merged 8 commits into
mainfrom
lazy-load-tabs
Jul 2, 2026
Merged

Lazy load bottom tabs#202
jayohms merged 8 commits into
mainfrom
lazy-load-tabs

Conversation

@jayohms

@jayohms jayohms commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

By default, an app with bottom tabs loads every tab's initial screen at startup — each tab's navigator immediately visits its start location, even for tabs the user may never open. For apps with several tabs, this means a burst of web view visits up front.

This PR adds an opt-in that defers each tab's initial load until the tab is first selected. The initially selected tab still loads right away; the others load the first time you tap into them, and stay loaded afterward. This spreads out the work and avoids paying for tabs that are never visited.

Eager loading remains the default, so existing apps are unaffected unless they opt in.

Public API changes

HotwireBottomNavigationController gains a new optional constructor parameter, lazyLoadTabs: Boolean = false. Set it to true to enable deferred tab loading:

HotwireBottomNavigationController(
    activity = this,
    view = bottomNavigationView,
    lazyLoadTabs = true
)

No other public APIs change, and the default (false) preserves the current behavior.

Notes

  • Deferral is scoped to bottom tab hosts only. Nested and standalone navigator hosts continue to load eagerly.
  • The demo app enables lazyLoadTabs to exercise the new behavior.

@jayohms
jayohms requested a review from mbarta July 2, 2026 16:29
@jayohms jayohms mentioned this pull request Jul 2, 2026
@jayohms
jayohms merged commit 75d91a6 into main Jul 2, 2026
1 check passed
@jayohms
jayohms deleted the lazy-load-tabs branch July 2, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant