We have a custom ribbon button and we have added code to refer JS file in it. The ribbon button is bound to content type.

ScriptSrc ="~sitecollection/Style Library/JS/MyProjectRibbonButton.js"/>

But MyProjectRibbonButton.js file is loaded on all the pages - site settings, home page - where the ribbon button is not event visible.

What is the cause of this issue?

Edit 1:

From Danny's comment below it seems that Location="ScriptLink" makes it load on all the pages. Any way I can make it load on only those pages where ribbon button is present?

  • 2
    It is not an issue, since SP2010 the CustomAction type ScriptLink is intended to load on all pages. Very powerful, alas does not execute on Microsofts Modern Experiences – Danny '365CSI' Engelman Dec 20 '16 at 9:41
  • @Danny'365CSI'Engelman: Any way I can make it to load on only those pages where ribbon button gets loaded? – Naveen Dec 20 '16 at 10:01
  • Show custom action in ribbon for only one list - check this link. You need to modify accordingly. – Gautam Sheth Dec 20 '16 at 10:05
  • @GautamSheth: I want to load the JS file where the ribbon button is present. As of now it loads across all the pages. Your link is for loading ribbon button and not JS file. – Naveen Dec 20 '16 at 10:14
  • @Naveen, no, a ScriptLink loads on all pages --period-- Have you read the Microsoft documentation about CustomActions? – Danny '365CSI' Engelman Dec 20 '16 at 10:28

Your Answer

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

Browse other questions tagged or ask your own question.