收藏
回答

Ask about code-package-size?

can you guys give me some tips on how to decrease code package size?

any tip and trick or hack

limit is only 20MB, i think my app will be quite big

回答关注问题邀请回答
收藏

3 个回答

  • 郑钱花
    郑钱花
    星期五 10:49

    从简单到复杂

    1.删除无效的静态资源,使用TinyPng压缩静态资源

    2.代码分包,tabbar的页面作为主包,tabbar对应的页面以及关联的二级页面作为一个分包,比如5个tabbar页面,就做5个分包

    3.分包之后静态资源也随着分包,要注意区分,只有分包里用到的资源才转移到分包,分包共用的图片只能放主包。

    4.图片按大小排序,上传至服务器后使用https链接替换,然后删除本地图片资源

    5.减少使用一些非必要的三方npm包,手写方法替换实现


    You can translate it yourself

    星期五 10:49
    有用
    回复 2
    • Andres99
      Andres99
      星期五 12:03
      Thank you very much
      But can u give me code example about 
      3. After subpackaging, static resources are also subpacked. Please pay attention to the distinction. Only the resources used in the subpackaging are transferred to the subpackaging, and the images shared by the subpackaging can only be placed in the main package.
      星期五 12:03
      回复
    • 郑钱花
      郑钱花
      9小时前回复Andres99
      比如有3张图片,main.png 、a.png、b.png。a.png仅在subpackageA里的页面被使用,则a.png可以移动至subpackageA的文件夹下面,这样主包就小了一张图片的大小,而分包subpackageA则变大了。subpackageB同理。
      需要注意的是,main.png如果被subpackageA里的页面和subpackageB里的页面同时使用时。你就只能让main.png放在主包里,不能放任何一个分包。
      参考文档https://developers.weixin.qq.com/miniprogram/dev/framework/subpackages/basic.html
      9小时前
      回复
  • 智能回答 智能回答 本次回答由AI生成
    星期四 17:05
    有用
  • Chlity
    Chlity
    星期四 17:05

    where are you from?

    星期四 17:05
    有用
    回复 2
    • Andres99
      Andres99
      星期四 17:08
      From Vietnam
      星期四 17:08
      回复
    • Chlity
      Chlity
      星期四 17:11回复Andres99
      unbelievable,This is China, please send Chinese
      星期四 17:11
      回复
登录 后发表内容