Immediate Layout
Overview
Some JavaScript methods require browsers to do an Immediate Layout to yield correct results. Prysm doesn’t do that by default as a layout is an expensive operation, but it is possible to enable the behavior on demand as third-party JavaScript libraries might depend on it.
What is affected
When Immediate Layout is enabled all getters from the list here execute a layout before returning a value.
Controlling the behavior
The default behavior is a view setting, so changing it affects all documents loaded in a view. It can be set by:
- Setting the
ViewSettings::EnableImmediateLayout
bool. - By calling the
engine.enableImmediateLayout
andengine.isImmediateLayoutEnabled
methods. - By calling the
View::EnableImmediateLayout
andView::IsImmediateLayoutEnabled
methods.
What is more, an immediate layout can be triggered on demand through the engine.executeImmediateLayoutSync
method.
Workflow comparison
Enabling Immediate Layout will trigger a layout on each getter which might be rather expensive. This is the easiest way to test how a third-party library works.
A more optimal workflow would be to perform as many changes as possible, then doing a single engine.executeImmediateLayoutSync
and then calling getters many times. With that flow, a single layout is executed and the performance of an application should improve.