From 4e59e868aae1378122741507327ead33a99dcff8 Mon Sep 17 00:00:00 2001 From: tikkhun Date: Sat, 13 Dec 2025 23:23:49 +0800 Subject: [PATCH] =?UTF-8?q?perf(=E5=9B=BE=E7=89=87=E5=8A=A0=E8=BD=BD):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=BE=E7=89=87=E5=8A=A0=E8=BD=BD=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E7=AE=80=E5=8C=96=E8=A7=A3=E7=A0=81=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除冗余的解码检查逻辑,直接使用现代浏览器的异步解码特性 添加fetchPriority优化加载优先级,提升页面性能 --- js/shapes/utils.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/js/shapes/utils.js b/js/shapes/utils.js index fe527de..66a0adf 100644 --- a/js/shapes/utils.js +++ b/js/shapes/utils.js @@ -21,14 +21,9 @@ const img = new Image(); const record = { img: img, ready: false }; window.YooneSnowImageCache[imageUrl] = record; - img.onload = function(){ - var decoder = img.decode && typeof img.decode === 'function' ? img.decode() : null; - if (decoder && typeof decoder.then === 'function'){ - decoder.then(function(){ record.ready = true; }).catch(function(){ record.ready = true; }); - } else { - record.ready = true; - } - }; + try { img.decoding = 'async'; } catch(e) {} + try { img.fetchPriority = 'low'; } catch(e) {} + img.onload = function(){ record.ready = true; }; img.onerror = function(){ // 加载失败 从缓存移除避免重复错误 delete window.YooneSnowImageCache[imageUrl];