What techniques can I use to make JS-heavy pages performant on mobile devices?

前端 未结 3 558
渐次进展
渐次进展 2021-02-09 12:30

I have a site that involves a large amount of JS code (~100K including jQuery). When I browse similar sites on my phone or tablet, I\'m usually disappointed at how sluggish they

3条回答
  •  -上瘾入骨i
    2021-02-09 12:48

    Latency is the killer in the mobile environment so one of the first things to concentrate on is reducing requests, for example:

    Inline the CSS and JS, then split them out and cache in localstorage (Bing mobile does this)

    Alternatively inline the JS and wrap in comments then remove the comments and eval the JS (Mobile gmail used to do this - don't know whether it does)

    Use data-uri's for images

    Switch from jquery to a slimmer framework like zepto.js

    Don't use large -ve offsets to hide items from view.

    If you find @standardista's presentation from Velocity EU, it contains a whole series of other thoughts.

提交回复
热议问题