1/** 2 * Lazy-load the search Vue app (PAD1-1315, INP). 3 * 4 * The search app (js/app.js, ~200 KB) used to load + mount on every page, costing 5 * ~95ms of main-thread work even though it's only used when the user opens search. 6 * This tiny vanilla loader is attached instead; it injects app.js + app.css on the 7 * first interaction with a search trigger, so the bundle stays off the critical path 8 * until it's actually needed. The app's mount point (#prg-search-app) and its 9 * drupalSettings are already on the page, so app.js mounts as soon as it loads. 10 */ 11(function () { 12 'use strict'; 13 var settings = (window.drupalSettings && window.drupalSettings.prg_search_app) || {}; 14 var loaded = false; 15 16 function loadSearchApp() { 17 if (loaded) { return; } 18 loaded = true; 19 if (settings.appCss) { 20 var link = document.createElement('link'); 21 link.rel = 'stylesheet'; 22 link.href = settings.appCss; 23 document.head.appendChild(link); 24 } 25 if (settings.appJs) { 26 var script = document.createElement('script'); 27 script.src = settings.appJs; 28 script.defer = true; 29 document.body.appendChild(script); 30 } 31 } 32 33 function bind() { 34 // Dedicated search results page (node 30448): the app is rendered as the main 35 // page content, OUTSIDE the header's #search overlay, and there is no .hledej
36 // trigger to click â so it must mount immediately, not on interaction. 37 var apps = document.querySelectorAll('#prg-search-app'); 38 for (var i = 0; i < apps.length; i++) { 39 if (!apps[i].closest('#search')) { 40 loadSearchApp(); 41 return; 42 } 43 } 44 45 // Header overlay (every other page): desktop search button, mobile search icon, 46 // and the overlay itself â load on first interaction. 47 var triggers = document.querySelectorAll('.hledej, .mobile-menu-header-icons .search, #search'); 48 for (var i = 0; i < triggers.length; i++) { 49 // Start loading on the earliest hint of intent (pointer/touch/focus) so the 50 // bundle is usually ready by the time the overlay finishes opening. 51 ['mousedown', 'touchstart', 'focusin'].forEach(function (evt) { 52 triggers[i].addEventListener(evt, loadSearchApp, { once: true, passive: true }); 53 }); 54 } 55 } 56 57 if (document.readyState === 'loading') { 58 document.addEventListener('DOMContentLoaded', bind); 59 } else { 60 bind(); 61 } 62})();
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.