I am working on a SP2013 on-premise farm and try to create a custom page layout. There are some JQuery function I need it render on particular custom page layout but not other pages.

<script type="text/javascript">//<![CDATA[  

I added above snippet to my custom page layout html. It doesn't renderat all. However when I added it to the same location of my custom Master page, it works.

May I know what is the suggested way to add JS or JQuery to custom layout page? Thanks.

3 Answers 3


In your custom page layout first add path to .js file (put path to src="") and then code.

<script src="jquery-1.8.3.min.js">//<![CDATA[


            //some code         

<!--MS:<Publishing:EditModePanel runat="server" id="editmodestyles">-->

Place it just above the Publishing:EditModePanel tag

  • Oh! It works now. The only change I made is moving the snippet above Publishing:EditModePanel tag. Why it makes the different?
    – Mark L
    Jul 2, 2015 at 8:11
  • It must be before all that publishing registration for jquery to work. Please mark as answer. :)
    – Marko Tica
    Jul 2, 2015 at 8:24

You can also add your scripts in the following section too.

 <SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" 


If you are only after using (simple) jQuery selectors.

Microsoft has this thing called mQuery built in SharePoint.

So jQuerys:




straight out of the box, without the need for jQuery

It is loaded on most pages (check in F12 developer tools)
if not, use:

EnsureScriptFunc('mQuery.js', 'm$', function() {


Note that with not too complex JavaScript; jQuery "magic" can be done without jQuery;
http://youmightnotneedjquery.com/ is a very good read

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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