2

I have a site collection on the root directory http://pc51:1001 and a site collection under the sites directory http://pc51:1001/sites/First .

I am trying to add jQuery file reference in Master Page so it will work on both site collections

What is the best practice method for adding a jQuery reference in the Master Page?

My jQuery file resides in /Style Library/ABC/Js/jquery-1.10.2.min.js

Robert Lindgren
  • 24,520
  • 12
  • 53
  • 79
Akshay Dattatray Nangare
  • 3,392
  • 9
  • 59
  • 105
  • 1
    If this isn't a duplicate of http://sharepoint.stackexchange.com/questions/86979/adding-jquery-to-master-page?rq=1 then it's a duplicate of http://sharepoint.stackexchange.com/questions/151177/adding-jquery-and-bootstrap-references-to-master-page?rq=1 (and tons of other similar questions)... and the accepted answer will break MDS for 2013/O365 users, so is actively harmful – John-M Apr 07 '16 at 11:58
  • i have found those question that u had mention , And I have checked his answer,it does not work .so i had post this question. the answer given by Hardik worked for me.. – Akshay Dattatray Nangare Apr 08 '16 at 06:18

1 Answers1

0

You can use below line in your master page to access your JS file anywhere from entire site collection.

<script type="text/javascript" src="<asp:Literal runat='server' Text='<%$SPUrl:~sitecollection/Style Library/Envera/Js/jquery-1.10.2.min.js%>' />"></script>
Hardik
  • 7,733
  • 2
  • 18
  • 37