For developers who want to add advanced functionality, there are some custom events you can listen for.

wmSectionLoader:loaded

The wmSectionLoader:loaded event fires after each sectionLoader has loaded. This event comes with a detail object with the target url for the loaded section.

<!-- Section Loader Custom Event -->
<script>
document.addEventListener('wmSectionLoader:loaded', ({detail}) => {
  if (detail.target !== '/example-url') return; // Look for a specific loader
  
  // code here will run after a section loader pulls 
  // in the content from the '/example-url' page
  
})
</script>
 

wmSectionLoader:scriptsLoaded

The wmSectionLoader:scriptsLoaded event fires after all sections have loaded and the Squarespace initialization script has run. This is good when using more complex Squarespace components, like list sections or gallery sections.

<!-- Section Loader Custom Event -->
<script>
document.addEventListener('wmSectionLoader:scriptsLoaded', () => {

});
</script>

Previous
Previous

Can I self-host this code?