You can write a fonctionfunction on a specific script file and call it in to your body element, by using onload attribute.
Exemple:
<script>
afterPageLoad() {
//your code here
}
</script>
Now call your script into your html page by using script tag:
<script src="afterload.js"></script>
into your body element; add onload attribute like this:
<body onload="afterPageLoad();">