This link talks about a function called RegisterModuleInit()
, which tells MDS to exclude a particular JavaScript file with an entry point function from MDS. While the blog post is specific to JSLinks, perhaps it'll work for you.
RegisterModuleInit()
takes two parameters. The first parameter is the path to the JavaScript file. The second parameter is the entry point function. Let's assume your custom JavaScript is saved in the master page gallery, and is called MyScripts.js. Let's assume your custom JavaScript file contains a function that needs to be ran on page load, and it is called MyScriptLoadFunction()
. Try adding this to your master page (make sure you load your JavaScript file as you would normally):
<script type='text/javascript'>
RegisterModuleInit('/_catalogs/masterpage/MyScripts.js', MyScriptLoadFunction);
MyScriptLoadFunction();
</script>
Documentation on RegisterModuleInit()
is scarce, and I've only used it for JSLinks. I hope this works for you.