1

I have created a custom master page and added a custom js reference to that master page using scriptlink tag. But once MDS feature is enabled on site, master page can not load custom js, it gives js load error on the same page.

How can this be resolved?

  • have you tested if it is reachable via the link you provided? – Gwny Jun 12 '14 at 6:45
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.