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.
<CustomAction
Id="MyProject.RibbonButton"
Location="ScriptLink"
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?