1: Dynamic resources

This method is often the main cause of early bloat and the most efficient way to compress small programs.

Some non-core and non-urgent resource files, especially large media files such as pictures, audio and videos, can be moved to the CDN server and downloaded when needed.

2: Dynamic pages

Turn the non-core and non-urgent pages into H5 and display them through webView. One page and two pages won’t make much difference, but if there are 10 pages and 8 pages, it will be obvious, saving at least a few tens of KB.

3: static data line

Sometimes in development, we will put some unchanged data into small program projects, such as city address information, terms of service, etc., such data as far as possible to go online, when the first load can be cached to the local.

4: Clean up waste resources in time

Clear offline or abandoned file resources, including NPM packages, components, pages, and media resources. If you need to go online or use it again, you can use a version control tool such as Git to retrieve it. This part of the resource does not need to continuously occupy the code package space

5: Remove duplicate code

You can use Sonar to analyze project code and find out which code is repetitive and can be optimized for it.

6: Extract the public module

Business implementation is made common, extracting common business components, such as different activities can adopt the same template, the same component, without adding new code every time.

The style level is kept uniform, and the basic components are unified. For example, the popover specification can be unified, instead of introducing various fragmented popover components.

Design and development level to reduce duplication, more extraction of common modules, reduce repeated wheel.

7: Use tripartite plug-ins with caution

Use third-party plugins as little as possible, such as Echart, where you may only need 1% of its functionality, a graph, but have to package it and make the whole project explode in size.

8: Configuration subcontracting (general subcontracting)

Subcontracting refinement