Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add pre-rendering and persistent rendering modes. #501

Merged
merged 40 commits into from
Jan 30, 2024

Conversation

andycall
Copy link
Member

@andycall andycall commented Oct 10, 2023

This PR adds two load modes, allowing developers to preload and prerender web pages before these pages are mounted into the Flutter tree.

  1. The Preloading mode: /Preloads remote resources into memory and begins execution when the WebF widget is mounted into the Flutter tree. If the entrypoint is an HTML file, the HTML will be parsed, and its elements will be organized into a DOM tree. CSS files loaded through <style> and <link> elements will be parsed and the calculated styles applied to the corresponding DOM elements. However, JavaScript code will not be executed in this mode. If the entrypoint is a JavaScript file, WebF only do loading until the WebF widget is mounted into the Flutter tree. Using this mode can save up to 50% of loading time, while maintaining a high level of compatibility with the standard mode. It's safe and recommended to use this mode for all types of pages.
  2. The aggressive mode is a step further than preloading, cutting down up to 90% of loading time for optimal performance. This mode simulates the instantaneous response of native Flutter pages but may require modifications in the existing web codes for compatibility. In this mode, all remote resources are loaded and executed similarly to the standard mode, but with an offline-like behavior. Given that JavaScript is executed in this mode, properties like clientWidth and clientHeight from the viewModule always return 0. This is because no layout or paint processes occur during preRendering. If your application depends on viewModule properties, ensure that the related code is placed within the load and DOMContentLoaded event callbacks of the window. These callbacks are triggered once the WebF widget is mounted into the Flutter tree. Apps optimized for this mode remain compatible with both standard and preloading modes.
image

@andycall andycall changed the base branch from main to feat/pre_load October 10, 2023 13:55
Base automatically changed from feat/pre_load to main November 6, 2023 10:26
@andycall andycall changed the title [WIP]: Feat: Add pre-rendering and persistent rendering modes. Feat: Add pre-rendering and persistent rendering modes. Nov 20, 2023
@andycall andycall force-pushed the feat/offline_rendering branch 2 times, most recently from c081663 to 3e3939c Compare December 4, 2023 04:02
@andycall andycall changed the base branch from main to feat/feat/dedicated_js_thread_v2 December 4, 2023 04:03
@andycall andycall force-pushed the feat/feat/dedicated_js_thread_v2 branch 2 times, most recently from 3db0328 to 4dbfca3 Compare December 27, 2023 08:35
@andycall andycall force-pushed the feat/feat/dedicated_js_thread_v2 branch from 1ecfb58 to 79dc274 Compare December 28, 2023 07:52
Base automatically changed from feat/feat/dedicated_js_thread_v2 to main December 28, 2023 08:46
@andycall andycall added this pull request to the merge queue Jan 30, 2024
Merged via the queue into main with commit 7cf651a Jan 30, 2024
27 checks passed
@andycall andycall deleted the feat/offline_rendering branch January 30, 2024 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants