From fb3698b4bff01e95a5705f3296fb62396715944e Mon Sep 17 00:00:00 2001 From: gocivici Date: Sun, 25 Feb 2024 16:58:31 +0300 Subject: [PATCH] - js image preload for firefox --- public/index.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/public/index.js b/public/index.js index 587f0d4..9bc7e9a 100644 --- a/public/index.js +++ b/public/index.js @@ -18,11 +18,16 @@ let pageVisible = true; let debugMode = false; let timeoutHandle; -//preload images -new Image().src = 'characterSprites/Red/Down.png'; -new Image().src = 'characterSprites/Red/Up.png'; -new Image().src = 'characterSprites/Red/Left.png'; -new Image().src = 'characterSprites/Red/Right.png'; +//preload images to avoid firefox NS_BINDING_ABORTED error +const characters = ["Green","Red","Orange","Blue"]; +characters.forEach((char) => { + new Image().src = 'characterSprites/'+ char +'/Down.png'; + new Image().src = 'characterSprites/'+ char +'/Up.png'; + new Image().src = 'characterSprites/'+ char +'/Left.png'; + new Image().src = 'characterSprites/'+ char +'/Right.png'; +}); + + //emoji picker code