/* JS Speed Booster for Salla – by Qorsh 2025 */ /* 1. تأخير السكربتات الثقيلة */ document.addEventListener("DOMContentLoaded", function () { const scripts = document.querySelectorAll('script[src]'); scripts.forEach(script => { if (!script.src.includes('salla') && !script.src.includes('checkout')) { script.setAttribute('defer', ''); } }); }); /* 2. تسريع الضغطات على الجوال (Instant Tap) */ document.addEventListener('touchstart', function () {}, {passive: true}); /* 3. تعطيل الأنيميشن الثقيلة على الجوال */ if (window.innerWidth < 768) { const disableAnimations = () => { document.querySelectorAll('*').forEach(el => { el.style.transition = '0.1s linear'; el.style.animation = 'none'; }); }; window.addEventListener('load', disableAnimations); } /* 4. تحسين الصور – Lazyload Boost */ document.addEventListener("DOMContentLoaded", function () { const imgs = document.querySelectorAll('img'); imgs.forEach(img => { img.setAttribute('loading', 'lazy'); img.decoding = "async"; }); }); /* 5. تحسين السلايدر (Swiper Speed Upgrade) */ document.addEventListener("DOMContentLoaded", function () { const sw = document.querySelectorAll('.swiper-wrapper'); sw.forEach(slider => { slider.style.transitionTimingFunction = "linear"; }); }); /* 6. إزالة العناصر غير الضرورية لتقليل DOM Size */ window.addEventListener("load", function () { const elementsToRemove = [ ".s-footer-social", ".s-payments-list" ]; elementsToRemove.forEach(sel => { const el = document.querySelector(sel); if (el) el.remove(); }); }); /* 7. منع تحميل الخطوط غير الضرورية */ document.addEventListener("DOMContentLoaded", function () { const links = document.querySelectorAll('link[rel="preload"], link[rel="prefetch"]'); links.forEach(link => { if (link.href && link.href.includes('googleapis')) { link.remove(); } }); }); /* 8. إخفاء التحميل البطيء لزيادة الشعور بالسرعة */ document.onreadystatechange = function () { if (document.readyState === "complete") { document.body.classList.add("page-loaded"); } };