Embed static contents into collection page

Hi there! :grinning:

I’m building a rather big page for a customer. Initially we thought, all his services could be layouted into one template (aka collection page), but it turns out that this feature turns out to be a limitation to the content (some need a comparison table, others have 5 anchor links, it get’s too complicated for a collection to make sense). In short: Every service page has to look different now, but still has many things in common with its siblings.

I would like to keep the collection for the repeating things but have them embed certain static pages. I played around with this https://webflow.com/website/ajax-content-load nice example here, but it requires the user to click on a link
javascript:loadcontent();

for the JS to do it’s job:

<script>
function loadcontent {
$('#viewport').load('../test-page');
}
</script>

How can I start the JS script automatically when the page loads? Or is there a total alternative for me to do this in a better way?

Thank you very much! :boom: