Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've added my JavaScript code by including the script links in the PlaceHolderAdditionalPageHead <asp:Content> tag. Including this has caused a yellow warning stating

The current page has been customized from its template. Revert to template.

I understand that I can simply remove the message through some JavaScript code, but how does Microsoft recommend I include JavaScript code and jQuery without disrupting the site template?

share|improve this question
add comment

5 Answers

up vote 5 down vote accepted

It really depends what page you are talking about (master page, .aspx page, etc.), but you can add your script references in a Content Editor Web Part (CEWP) if you don't want to customize your pages.

share|improve this answer
add comment

Are you running SharePoint 2010? If so, you can include your scripts using a feature: it is now possible to have a CustomAction with ScriptLink as a location. This will leave the masterpage unmodified while at the same time making jQuery (and any other scripts you need) available across the entire site collection. More information is in Deploying and Using jQuery with a SharePoint 2010 Sandboxed Solution.

share|improve this answer
    
Completely forgot about that one! That is, indeed, a nice solution. –  Bas Lijten Aug 29 '11 at 7:15
add comment

A warning doesn't mean that you did something wrong.

As far as I know there is no recommendation from Microsoft. There are many ways to add a script to a page, and your choice will depend on your specific use case and personal preferences.

Do you need jQuery on many pages? Then you may want to include it in a custom Master page. Do you need it on just one page? Then the easiest way is to call it from a Content Editor Web Part.

share|improve this answer
    
I like this contribution though not as complete as some of the other answers just because it mentions that the warning is just a warning. –  Tom Resing Aug 30 '11 at 20:00
add comment

As Marc D Anderson stated, you can add script references in various ways. If you want to add JavaScript code on a single page, you can indeed use a Content Editor webpart, but I really like the solution of creating a feature and use delegate controls to add the JavaScript code to your page layouts. That way, you don't have to customize any page layouts.

Read jQuery Templates and the Sharepoint 2010 Object Model for information on adding JavaScript code to pages.

share|improve this answer
2  
delegate controls means filesystem deployment, if you are on SP2010 and in a sandboxed environment this won't work –  Colin Aug 26 '11 at 20:27
add comment

It is not recommended to customize any out of the box master pages or page layouts in SharePoint. Instead, copy your existing master page to a new name and make your customizations in that, then set the new master page as the master page for your site collection.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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