We have applied a javascript file against a partial page however we have found that the javascript file is being loaded when the calling page is being loaded.
We know this as we were calling a dojo.ready call in the javascript file in the partial page.
This can be recreated adding a js file against a partial page with the following code
dojo.ready(function{ alert('Hello World!'); });
As the main page is loaded it also loads the partial page's javascript.
To get around the problem we added a custom control on to the partial page with the following code
<script type='text/javascript>
dojo.ready(function{ alert('Hello World!'); });
</script>
Why does the partial pages jscript get called by the main page?
We know this as we were calling a dojo.ready call in the javascript file in the partial page.
This can be recreated adding a js file against a partial page with the following code
dojo.ready(function{ alert('Hello World!'); });
As the main page is loaded it also loads the partial page's javascript.
To get around the problem we added a custom control on to the partial page with the following code
<script type='text/javascript>
dojo.ready(function{ alert('Hello World!'); });
</script>
Why does the partial pages jscript get called by the main page?
RE: Application vs Page javascript files
This means that the script files are loaded for the Page, but aren't called until the Partial Page events call them.
So, it is better to have an onload event against the Partial Page to ensure it is only fired when the Partial Page is loaded. It is desirable to avoid dojo.ready or onload type into the JavaScript files, as they are not as visible as a Page Design onload event.
RE: Application vs Page javascript files
What we have found is that if we put our code in the onload event of the page we were getting jscript errors as the dojo objects didn't appear loaded. By making use of the dojo.ready it made sure the dojo objects were fully loaded and we didn't get the jscript error.