Resource Loading Optimization

View Markdown

Last edited on 2026-06-16

1. Controlling Image Resource Size

Developers should select appropriate image dimensions, formats, and compression ratios based on functional requirements and the actual display area size.

Excessive image file sizes may lead to the following consequences:

  • Increased image download time, causing delays in users seeing the images;
  • Unnecessary data consumption for users;
  • Increased time spent on image decoding and rendering, which may more easily cause frame drops, stuttering, or white screens, and even prevent normal scrolling and page transitions (this is particularly noticeable on low-end devices);
  • Increased memory usage, especially when large images or a large number of images in long lists cause a sharp rise in memory consumption.

Impact of Images on Memory

When iOS memory is under pressure, the system proactively reclaims some WebView instances. Large images and a large number of images in long lists can easily trigger the system to reclaim WebViews, resulting in Mini Program white screens. In severe cases, this may force WeChat to close Mini Program.

If memory growth exceeds the limit, it may also cause Mini Program to display white or black screens, or even crash the entire Mini Program.

2. Avoid abusing the widthFix/heightFix mode of the image component

The widthFix/heightFix mode dynamically changes the image height or width after the image loading is completed. Dynamic changes to image height or width may trigger large-scale layout reflows within the page, causing page jitter and stuttering.

For page background images or banner images, the image dimensions should be pre-specified as much as possible to avoid secondary dimension adjustments after the image loading is completed.