i am working on a team site inside my SharePoint server 2013. I need to add a Java script code to my master page , so that the script will be available to all my SharePoint web pages. but i can not figure out where i should add the script to my master page ? and should i added it to the Seatle.master or other mater pages . any advice ?

1 Answer 1


Create a JS File und put following line inside the <head> element:

<SharePoint:ScriptLink language="javascript" name="custom.js" runat="server"/>

And yes seattle.master is the right place for it, if you want to run your JS Code on non-administrative pages.

To learn how to provide Custom Javascript files to SharePoint have a look here: more detailed explanation.

  • so i create a Script file named "custome.js" and then i upload it to my site assets, or where i should create the custome.js script file ?
    – John John
    Commented Sep 3, 2013 at 11:08
  • If you only need it in your site collection, you could put it into a document library at the root site collection. For example http://[host]/Scripts/. But be aware, that other users may access this library. Another possibility is to place into the file system under `C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS`. For better management you can create a subfolder here to encapsulate your assets.
    – wu5chl
    Commented Sep 3, 2013 at 11:12
  • i have added <SharePoint:ScriptLink language="javascript" name="custom.js" runat="server"/> after m <head>, and i added the cusotm.js insdie the template\layouts but doing so will show black pages for all my site collection pages ...
    – John John
    Commented Sep 3, 2013 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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