// include 완료 후 여러 js 파일 순서대로 실행 window.addEventListener('DOMContentLoaded', function () { const includeTargets = document.querySelectorAll('[data-include-path]'); let includeCount = 0; includeTargets.forEach(el => { const includePath = el.dataset.includePath; const xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function () { if (this.readyState === 4 && this.status === 200) { el.outerHTML = this.responseText; includeCount++; // 모든 include 완료 시점 if (includeCount === includeTargets.length) { loadScriptsSequentially([ '../layout/layout.js', '../script/tab.js', '../script/popup.js', '../script/content.js', '../script/toggleCalendar.js' ]); } } }; xhttp.open('GET', includePath, true); xhttp.send(); }); // 스크립트 순서대로 로드하는 함수 function loadScriptsSequentially(scripts) { if (!scripts.length) return; const src = scripts.shift(); const script = document.createElement('script'); script.src = src; script.onload = () => loadScriptsSequentially(scripts); document.body.appendChild(script); } });