To delay the initial page load and then dynamically load a sub page in Webflow using JavaScript, you'll need to use custom code to control loading behavior and fetch content. Webflow doesn’t natively support dynamic sub-page loading, so you’ll be using JavaScript to simulate this behavior.
window.onload
or DOMContentLoaded
to trigger a delay after the main page is ready.tag in the page where you want the delay.
Example:
window.addEventListener('DOMContentLoaded', function () { setTimeout(function () { loadSubPageContent(); // Call your custom function after delay }, 2000); // 2000ms = 2 seconds delay});
fetch()
to load HTML content from another page in your Webflow site.<div id="sub-page-container"></div>
element in your main page to inject the sub page content.Example function:
function loadSubPageContent() { fetch('/sub-page') // replace with your actual sub-page slug .then(function (response) { return response.text(); }) .then(function (html) { // Extract the part you want if needed const parser = new DOMParser(); const doc = parser.parseFromString(html, 'text/html'); const subContent = doc.querySelector('#target-section'); // change selector as needed document.getElementById('sub-page-container').appendChild(subContent); });}
<section id="target-section">...</section>
.To delay page load and load a sub page in Webflow, use setTimeout
to delay execution, then fetch sub page content via JavaScript and inject it into the DOM. Wrap target content in the sub page with a unique ID for easy selection.