How do I add an external javascript file to my custom master

Posted by Community Admin on 05-Aug-2018 15:34

How do I add an external javascript file to my custom masterpage?

All Replies

Posted by Community Admin on 26-Sep-2012 00:00
I'm actually trying to add a javascript file that my custom masterpage will load. How do I go about adding this? I know I could add a javascript widget within the CMS admin but I'd prefer to have it referenced from the masterpage.

I got the BlueMasters theme and am altering it. I noticed that it doesn't actually reference the stylesheet in the head. The stylesheet is in the App_Themes>BlueMasters>Global 
How does Sitefinity know where the stylesheet is? Would a .js file be loaded in the same way? 

Thanks for you help!
Posted by Community Admin on 26-Sep-2012 00:00
Ok I've answered my own question as far as adding a Javascript file. You add this code to your user control or masterpage.

<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sf" %>
<sf:ResourceLinks ID="resourcesLinks" runat="server">
    <sf:ResourceFile JavaScriptLibrary="JQuery" />
</sf:ResourceLinks>
You could replace JQuery with MooTools or Prototype.

 or its possible to add your own external javascript file

<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sf" %>
<sf:ResourceLinks ID="ResourceLinks1" runat="server">
    <sf:ResourceFile Name="~/Scripts/myJavascript.js" />
</sf:ResourceLinks>
This thread is closed