-
Notifications
You must be signed in to change notification settings - Fork 37
Using the LayoutFixer (beta)
Guy Sopher edited this page Oct 15, 2020
·
1 revision
The Layout Fixer is a special element that uses a web component to apply a "quick fix" to a responsive layout after an SSR and before the hydrate.
Since the gallery is using the container measurements to create a responsive layout, SSR cannot render the accurate layout. The only real layout can be created in the client, which will delay the TTI and have a negative effect on performance. To solve this issue, we've created a special flow for responsive layouts in SSR:
- Without a specified width, the server will render a fixed-width layout, with opacity:0 on the items
- In addition, the server will render a script tag with the Layout Fixer bundle
- The Layout Fixer will measure the container and create the layout. Then it will apply the correct dimension and position styles and set the item opacity to 1.
- The client will create a full and interactive layout.
The use the layout fixer you need to:
- Bundle it separately
- Render it when needed.
Use the playground's SSR Simulator example:
- Importing and running the web component
-
Creating a separate bundle for the Layout Fixer.
Notice: This step will differ according to your framework. It will usually be a part of your
package.json
- Rendering the Layout Fixer with the Gallery. Notice: Render the Layout Fixer only if the container dimensions are unknown