1document.addEventListener('DOMContentLoaded', () => { 2 const elements = document.querySelectorAll('[data-load="defer"]'); 3 4 // Inject CSS keyframes directly in the <head> if not already present 5 if (!document.getElementById('inline-spinner-style')) { 6 const style = document.createElement('style'); 7 style.id = 'inline-spinner-style'; 8 style.innerHTML = ` 9 @keyframes spin { 10 to { transform: rotate(360deg); } 11 } 12 `; 13 document.head.appendChild(style); 14 } 15 16 elements.forEach((el) => { 17 const slug = el.getAttribute('data-slug'); 18 const post_id = el.getAttribute('data-post_id'); 19 const name = el.getAttribute('data-name'); 20 21 // Clean up attributes 22 el.removeAttribute('data-slug'); 23 el.removeAttribute('data-name'); 24 el.removeAttribute('data-load'); 25 26 // Insert inline animated spinner 27 el.innerHTML = ` 28 <div role="presentation" aria-hidden="true" 29 style=" 30 display: flex; 31 justify-content: center; 32 align-items: center; 33 min-height: 60px; 34 height: 100%; 35 "> 36 <div style=" 37 width: 24px; 38 height: 24px; 39 border: 3px solid #ccc; 40 border-top-color: #333; 41 border-radius: 50%; 42 animation: spin 1s linear infinite; 43 "></div> 44 </div> 45 `; 46 47 fetch(nova.admin_ajax, { 48 method: 'POST', 49 headers: { 50 'Content-Type': 'application/x-www-form-urlencoded', 51 }, 52 body: new URLSearchParams({ 53 action: 'nova_defer_load_template_part', 54 slug: slug, 55 name: name, 56 post_id: post_id, 57 }), 58 }) 59 .then((response) => response.text()) 60 .then((html) => { 61 el.innerHTML = html; 62 el.removeAttribute('style'); 63 el.setAttribute('aria-busy', 'false'); 64 }) 65 .catch((err) => { 66 console.error('AJAX load error:', err); 67 el.innerHTML = '<p role="alert">Error loading content.</p>'; 68 }); 69 }); 70 }); 71
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.