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

2

1 Answer 1

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>
3
  • I was looking for the same. It worked for me. Found this post at the right time. Cheers!
    – Aks
    Commented Apr 7, 2016 at 11:31
  • it worked for me... Commented Apr 7, 2016 at 11:32
  • 2
    This will break MDS for 2013/O365 users
    – John-M
    Commented Apr 7, 2016 at 11:58

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