SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following code, but I am very sure it will only work in the homepage of our website, and not when having the following scenario


<SharePoint:ScriptLink language="javascript" name="/js/SP.Ribbon.js" LoadAfterUI="true" OnDemand="false" runat="server" Localizable="false"/>

  ExecuteOrDelayUntilScriptLoaded(initCOBRibbon, '/js/SP.Ribbon.js');

Is there anyspecific way to put in the name attribut that it should be the layouts in the root?

share|improve this question
up vote 3 down vote accepted

ScriptLink is automatically linked to layouts folder in the hive (14-folder). So the name="/xxx/js/SP.Ribbon.js" goes to /web1/web2/_layouts/xxx/js/SP.Ribbon.js which is actually the same file as if it would be <root>/_layouts/xxx/js/SP.Ribbon.js

share|improve this answer
the last line in my example, Do I need to put the same path, or just the name of the file? – Esteban V Mar 5 '12 at 13:41
the name refers to the file path seen from 14\Layouts. So if your file is in 14\Layouts\my-awesome.js, the name is "my-awesome.js" If your script is inside a subfolder(s), add them into name with slash (not backslash): 14\Layouts\xxx\js\SP.Ribbon.js -> name="xxx/js/SP.Ribbon.js" – Anatoly Mironov Mar 5 '12 at 13:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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