How to add references to css and js files in HTML master pages. The files are residing in SharePoint libraries.
2 Answers
After trying out different options available online, I was able to achieve it by
JavaScript
<!--SPM:<SharePoint:ScriptLink ID="ConfigurationScriptLink" Name="~sitecollection/SiteAssets/js/FileName.js" runat="server"/>-->
CSS
<!--SPM:<SharePoint:CssRegistration ID="CSSCustom" Name="<% $SPUrl:~sitecollection/SiteAssets/css/FileName.css %>" runat="server" After="Themable/corev15.css"/>-->
I have added it following way. May be very odd!
CSS
<link rel="stylesheet" href="/sites/IFICTeamSite/SiteAssets/MasterPageCss/masterPageCustom.css" ms-design-css-conversion="no" />
-
Using
CssRegistration
has lot of advantages, for exampleAfter
will make sure the styles get applied after SharePoint styles (this ensures our custom styles take precedence) Jan 16, 2015 at 15:07