Edit to reflect two scenarios for handling MDS
So, this has become one of those lovely 'it depends' answers...
In the general case (yours):
Because you're using MDS, you need to use a ScriptLink control somehwere on your page (by modifying the page source directly, perhaps using SPD or VS -- no content or script editor web parts though).
According to one of the only coherent articles I've found about MDS in the MSDN Dev Center (that is, not on an individual's blog page)
Including CSS and JavaScript files using HTML style and script tags is not supported in MDS.
The way to add your script in a ScripLink control is something like this:
<SharePoint:ScriptLink language="javascript" name="~site/SiteAssets/testModule.js" runat="server" />
Note that the 'name' property is the path to the file using a URL token (more info on those can be found here). Without the URL token, the ScriptLink control will want to look in _layouts and your local language folder.
To make the script load each time you navigate to the page, you still need to use RegisterModuleInit...
Here is my sample js file that will do a console.log each time you navigate to the page:
function foo() {
console.log('foo called');
}
ExecuteOrDelayUntilBodyLoaded(function() {
RegisterModuleInit('/mySite/SiteAssets/testModule.js', foo);
foo();
});
You can also use the ScriptBlock control if you want to add script to your page in-line but still have MDS recognize it needs to run it when the page loads:
<SharePoint:ScriptBlock runat="server" >
// Your JavaScript code here.
</SharePoint:ScriptBlock>
Something to note: You may need to make some adjustments to your page, depending on how you edit it to insert the ScriptLink in order to remove a"Revert to Template" message, you can find answers on that here and here: Remove "The current page has been customized from its template.".
In the Client Side Rendering (CSR) case:
You use the RegisterModuleInit function to register your function with the MDS manager after you use a content item's JSLink property to reference the js file. This scenario has been covered in other answers on this site (such as my own to: Client-side rendering (JS Link) status changes in sharepoint list) and in various blogs around the internet, good examples include:
"Register CSR-override on MDS enabled SharePoint 2013 site" - Sridhar Raghunathan
"The correct way to execute JavaScript functions in SharePoint 2013 MDS enabled sites" - Wictor Wilén