Use asynchronous loading for large images.
In common frame loss scenarios, modify the code according to this rule whenever possible.
// code-linter.json5
{
"rules": {
"@performance/hp-arkui-image-async-load": "suggestion",
}
} @Entry
@Component
struct MyComponent {
build() {
Row() {
// Local image 4k.png
Image($r('app.media.4k'))
.border({ width: 1 })
.borderStyle(BorderStyle.Dashed)
.height(100)
.width(100)
}
}
} @Entry
@Component
struct MyComponent {
build() {
Row() {
// Local image 4k.png
Image($r('app.media.4k'))
.border({ width: 1 })
.borderStyle(BorderStyle.Dashed)
.height(100)
.width(100)
.syncLoad(true)
}
}
} plugin:@performance/all
For details about how to configure Code Linter check rules, see Code Linter.