I want to load some javascript after the page/form is ready. Where do I do this. 

.template /templates/basetemplate.html
.name Trigger script
.security Low3
<div class="row" data-formloaded="dostartup">
    <p id="changeme">This text will be changed by script</p>
<script type="text/javascript">
    function dostartup(me){
        alert("When you press ok the text will change");
        $("#changeme").html("I just changed the text");

This is what is needed.

Points to note:

data-fromloaded="functionname" this must be placed in a div somewhere in your page code.
function functionname(me){}; must be defined a script tag in the document. This is the code called with jquery element for the div containing the data-formload as me. You can have more than one, and then each will be called in the order they are added to the document.

Why is it like this?

When I page is initialized it happens in several steps. First the template is loaded. Then your page is added into the page. Then the page is generated based on LiveText and tags in the page. Then the page is served to the browser. Here a new step of processes is started. The html is loaded. All other links in header is resolved. The page is then rendered and links in body is loaded as the page is rendered. Since servers needs to load it's code in a certain order, it is not always easy to know where to add your own code. If you do the data-fomload="fuctionname", this make sure your code is loaded after all default initialization is done.