Optimize APL Template Performance
Previously, you learned about how to create efficient APL template designs to reduce the time it takes to render an APL document on an Alexa-enabled screen device. APL templates that perform at a lower level introduce higher latency and visual response times that can make an APL experience less engaging and usable. Eventually, this can impact the overall quality of your APL experience and the success of your skill. Amazon provides a set of best practices to reduce latency for your APL documents. This section expands on this, by showing you how to optimize template performance.
Consider performance impact whenever you are making decisions that affect your APL architecture and your template design. Review Optimize APL Document Rendering to understand when and how inefficiently designed APL templates contribute to latency. You should always consider performance as a critical factor for providing high quality experiences. Performance often competes with other quality aspects of APL templates.
- Less efficient template design can decrease performance as more APL components are being inflated and rendered on screen than necessary. For details about how to improve resource and design efficiency of templates, see Optimize Template Design.
- Highly versatile templates often indicate more complex APL templates. In such templates, responsiveness and localization is achieved by an “all-in-one” APL template approach. This approach often leads to voluminous APL package imports that demand more network and device resources when downloading and parsing these packages.
- Putting more features in one template — such as a lot of animations, interactive UI elements, and other dynamics — can improve the user experience. On the flip side, feature-rich experiences demand more on-device resources when rendering and facilitating the experience on the screen.
Make sure to test your APL experience on different devices, in particular those which are less capable in terms of their hardware.
Optimize use of APL template components
The following list expands on best practices that are already provided on the Reduce Latency for Your APL documents documentation page.
- Stay current with the latest APL version to set an APL templates document
version. If your APL templates go with an old APL version number, your templates opt out of added features and built-in performance improvements of newer APL versions.
- Reuse APL
Textcomponents whenever you can instead of adding duplicated
Textcomponents to your template. You can reuse a
Textcomponent by dynamically changing its value with data bindings or an APL
SetValuecommand. Markup support in the
textproperty also provides an opportunity to merge and resolve
- Keep your APL template design clean and concise, and avoid making unnecessary or excessive use of APL components. Review Optimize Template Design to learn best practices about how to make template design more efficient and optimize your design towards reusability.
- If you render a dynamic
ScrollViewof items that populate list data from the data source, be aware of the size of your list as it multiplies the number of APL components that are rendered to visualize a list item. Consider using a dynamic list data source and reduce the initial item count of your list as it is returned by your skill at the time the APL template renders on screen.
Reduce user perceived latency
When there is no more technical option to further reduce the time that it takes to render the screen, try the following actions to bring down the latency as it is perceived by a user:
- Delay rendering complex visual elements or executing APL commands that you observe take up more time to render the document. Consider setting an APL components initial
displaystate to hidden and reveal it by setting
displayto normal as part of a components
- Consider showing a loading screen experience for the time it takes to render or update your APL document. For instance, when executing an APL
SendEventcommand to initiate a cloud round trip to your skill, render a loading animation or any other visual element to show progress. With this approach, the skill response responds with a set of commands that end the loading animation.
Last updated: Nov 02, 2022