/* Add custom Js code below */ function loadExternalCSS(cssURL) { // إنشاء عنصر var link = document.createElement('link'); // تحديد خصائص عنصر link.rel = 'stylesheet'; link.href = cssURL; // إضافة العنصر إلى document.head.appendChild(link); } // استدعاء الفنكشن مع الرابط الخاص بـ CSS loadExternalCSS('https://td-sport.com/gg2.css'); //footer (function() { function addFooterContent() { var footerContainer = document.querySelector(".fs-rights"); if (footerContainer && !footerContainer.querySelector(".extra-footer-content")) { var newContent = document.createElement("span"); newContent.classList.add("extra-footer-content"); newContent.innerHTML = ' Run by: ' + 'Skylight'; footerContainer.appendChild(newContent); } } addFooterContent(); })(); (function () { console.log("🚀 بدء تحسين أداء aljabrh.com..."); document.addEventListener("DOMContentLoaded", function () { console.log("⚡ جاري تطبيق تحسينات الأداء..."); /*** 🖼️ تفعيل Lazy Loading للصور بدون التأثير على الأيقونات ***/ document.querySelectorAll("img").forEach(img => { if (!img.hasAttribute("loading")) { img.setAttribute("loading", "lazy"); } // لو صورة لوجو أو هيرو، نعطيها fetchpriority عالي if (img.classList.contains("logo") || img.src.includes("hero") || img.src.includes("banner")) { img.setAttribute("fetchpriority", "high"); } }); console.log("✅ تم تفعيل Lazy Loading + Priority"); /*** ❌ إصلاح الصور المكسورة (مع استثناء الأيقونات واللوجو) ***/ document.querySelectorAll("img").forEach(img => { img.onerror = function () { if ( !img.classList.contains("icon") && !img.src.includes("icons") && !img.src.includes("logo") && !img.src.includes("svg") ) { img.src = "https://aljabrh.com/fallback.jpg"; // تأكد إن الصورة البديلة دي موجودة img.alt = "الصورة غير متاحة"; } }; }); /*** ⏳ تأجيل تحميل السكربتات غير الضرورية ***/ document.querySelectorAll("script[src]").forEach(script => { if (!script.hasAttribute("async") && !script.hasAttribute("defer")) { script.setAttribute("defer", "true"); } }); console.log("✅ تم تأجيل السكربتات غير الضرورية"); console.log("🎯 كل التحسينات اتطبقت بنجاح!"); }); })();