1jQuery(document).ready(function ($) { 2 const urlParams = new URLSearchParams(window.location.search); 3 let cookieValue = Cookies.get('dimsCookie'); 4 5 // Suppression du cookie 6 if (urlParams.has("imgsizes=off")) { 7 Cookies.remove('dimsCookie'); 8 } 9 10 if (urlParams.get("imgsizes") === "on" || cookieValue) { 11 if (!cookieValue) { 12 Cookies.set('dimsCookie', 'true', { expires: 1 }); 13 } 14 15 // Ajout du bouton de désactivation 16 $('body').prepend('<div class="js-off-button" style="position: fixed; bottom: 50px; left: 50px; background-color: red; z-index: 10; padding: 10px 25px; cursor: pointer">IMGSIZES OFF</div>'); 17 18 $('.js-off-button').click(function () { 19 Cookies.remove('dimsCookie'); 20 urlParams.delete("imgsizes"); 21 window.location.search = urlParams.toString(); 22 }); 23 24 // Fonction pour remplacer les images par des placeholders 25 function replaceImageWithPlaceholder(img) { 26 let imgH = img.naturalHeight || $(img).height(); 27 let imgW = img.naturalWidth || $(img).width(); 28 let placeholder = `https://placehold.co/${imgW}x${imgH}`; 29 30 $(img).attr("src", placeholder); 31 } 32 33 // Gestion des balises <img> 34 $('img').each(function () { 35 if (this.complete) { 36 replaceImageWithPlaceholder(this); 37 } else { 38 $(this).on('load', function () { 39 replaceImageWithPlaceholder(this); 40 }); 41 } 42 }); 43 44 // Gestion des <picture> et <source> 45 $('picture source').each(function () { 46 let source = $(this); 47 let img = new Image(); 48 img.src = source.attr("srcset"); 49 50 img.onload = function () { 51 let placeholder = `https://placehold.co/${img.width}x${img.height}`; 52 source.attr("srcset", placeholder); 53 }; 54 }); 55 56 // Gestion des background images 57 $('div, span, a').each(function () { 58 let bgImage = $(this).css("backgroundImage"); 59 let match = bgImage.match(/url\((['"])?(.*?)\1\)/); 60 61 if (match) { 62 let img = new Image(); 63 img.src = match[2]; 64 65 img.onload = () => { 66 let placeholder = `https://placehold.co/${img.width}x${img.height}`; 67 $(this).css("backgroundImage", `url("${placeholder}")`); 68 }; 69 } 70 }); 71 } 72});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.