<!DOCTYPE HTML>
<html lang="en" th:replace="~{layoutFile :: layout(~{::section})}" xmlns:th="http://www.thymeleaf.org">
<section class="grid">
    <h1 class="page-title display-native --turbo-frames">
        <div class="actions__icon --turbo-frames" aria-hidden="true"></div>
        Turbo Frames: Decompose complex pages
    </h1>

    <p>
        Most web applications present pages that contain several independent segments. For a discussion page, you might have a navigation bar on the top, a list of messages in the center, a form at the bottom to add a new message, and a sidebar with related topics. Generating this discussion page normally means generating each segment in a serialized manner, piecing them all together, then delivering the result as a single HTML response to the browser.
    </p>

    <p>
        With Turbo Frames, you can place those independent segments inside frame elements that can scope their navigation and be lazily loaded. Scoped navigation means all interaction within a frame, like clicking links or submitting forms, happens within that frame, keeping the rest of the page from changing or reloading.
    </p>

    <p>
        Turbo Frames affords you:
    </p>

    <p>
        <strong>Efficient caching.</strong> In the discussion page example above, the related topics sidebar needs to expire whenever a new related topic appears, but the list of messages in the center does not. When everything is just one page, the whole cache expires as soon as any of the individual segments do. With frames, each segment is cached independently, so you get longer-lived caches with fewer dependent keys.
    </p>

    <p>
        <strong>Parallelized execution.</strong> Each defer-loaded frame is generated by its own HTTP request/response, which means it can be handled by a separate process. This allows for parallelized execution without having to manually manage the process. A complicated composite page that takes 400ms to complete end-to-end can be broken up with frames, where the initial request might take only 50ms, and three defer-loaded frames take 50ms each. Now the whole page loads in 100ms because the three 50ms-frames run concurrently, rather than sequentially.
    </p>

    <p>
        <strong>Ready for mobile.</strong> In mobile apps, you usually can’t have big, complicated composite pages. Each segment needs a dedicated screen. With an application built using Turbo Frames, you’ve already done the work of turning the composite page into segments. These segments can then appear in native sheets and screens without alteration (since they all have independent URLs).
    </p>

    <p>
        <a href="https://turbo.hotwired.dev/handbook/frames" target="_blank" class="button">Decompose with Turbo Frames</a>
    </p>
</section>
</html>