This article discusses an optimization procedure for Microsoft Office SharePoint Server 2007. The article describes how to create a detached page that downloads the Core.js file but that does not reference the Core.js file on a site. When you use this method, you can delay the download of the Core.js file for anonymous users until users can view the page. In this manner, the page is rendered more quickly.
This article describes how to use Microsoft Office SharePoint Designer 2007 to create a detached page that downloads the Core.js file but that does not reference the Core.js file on a SharePoint Server 2007 site.
On an Internet-facing site, users who are on low-bandwidth connections or on high-latency connections may experience slow performance when they first browse a site. For example, it may take a long time for the first page of a site to load because of the additional resources that sometimes must be downloaded. Although resources are frequently shared between pages on a site, and although these resources are cached on the client, the first page of a site may be slow to load.
This article describes an optimization procedure for SharePoint Server 2007. By default, all pages on a SharePoint Server 2007 site contain a reference to the Core.js file. The Core.js file, in its compressed form, is 54 KB. In many areas, this file is critical to the operation of the site. However, there are some areas in which this file is not needed.
In the optimization procedure, you create a new page layout. Then, you create a new page by using that page layout. In the new page, the Core.js file is removed from the list of resources that must be downloaded before the page is rendered for an anonymous user. When content on the page is readable, the Core.js file is downloaded in the background. Important
The optimization procedure that is discussed in this article is not supported.
Before you perform this procedure, make sure that the following criteria are met:
To create a new page that downloads the Core.js file but that does not reference the Core.js file, follow these steps:
- In SharePoint Designer 2007, create a new page layout. To do this, copy an existing page layout and then paste it to the same folder.
For example, copy ArticleLeft.aspx, and then name the new page layout "ArticleLeftNoCore.aspx."
Note To distinguish between the two page layouts, you may want to specify a new description for the new page layout that you created.
After you create the new page layout, follow these steps:
- Double-click the new page layout. For example, double-click ArticleLeftNoCore.aspx. Then, at the bottom of the page, click Code.
- Locate the PlaceHolderAdditionalPageHead tag, and then add the following code to the tag.
When you do this, the server does not reference the Core.js file unless the Core.js file is registered by a control.
Other master pages may use a different tag to reference the ScriptLink control. For example, the Default.master page uses the "SharePoint:ScriptLink" tag instead of the "SharePointWebControls:ScriptLink" tag.
The tag that references the ScriptLink control references the Microsoft.SharePoint.WebControls namespace. The following tag is an example of such a tag.
<%@ Register Tagprefix="SharePointWebControls"
Assembly="Microsoft.SharePoint, Version=188.8.131.52, Culture=neutral,
- Create a new binary that is based on the following code. For example, create a new binary that is named "PerfTools.dll."
This code tells the server to reference the Core.js file if the user is not anonymous. This operation is performed because the Site Actions menu requires the Core.js file. By default, many authenticated users have access to the Site Actions menu on the site.
public class RegisterCoreWhenAuthenticatedControl : WebControl
protected override void OnInit(EventArgs e)
Your environment may require that you suppress the Core.js file under different circumstances. In this environment, use code that is appropriate to your needs.
Be aware that the OnInit method is run any time that the page is loaded. Therefore, make sure that you do not add code that adversely affects throughput on the server. For example, if you add code that accesses the current SpListItem component, a round trip to the Microsoft SQL Server database is likely to occur.
After you create the new binary, follow these steps:
- Set the version of the binary to 184.108.40.206.
- Add the binary to the global assembly cache on the server.
- Open the Web.config file on the server, and then add the following code to the set of SafeControls controls.
<SafeControl Assembly="PerfTools, Version=220.127.116.11, Culture=neutral, PublicKeyToken=PublicKeyToken" Namespace="WebControls" TypeName="*" Safe="True" />
- In the new page layout that you created in step 1, follow these steps:
- Add a tag to register the binary. The following tag is an example of such a tag.
<%@ Register TagPrefix="PerfTools" Namespace="WebControls"
Assembly="PerfTools, Version=18.104.22.168, Culture=neutral,
- On the line after the code that you added in step 1b, add the following code.
- Create a new page that is named "CorePreLoad.aspx," and then copy it to the "_layouts" folder on the server.
Use the following code to create the page.
This page references a function in the Core.js file. Additionally, the page downloads the Core.js file before it runs the file.
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint, Version=22.214.171.124, Culture=neutral,
<SharePoint:ScriptLink name="core.js" runat="server" />
- Open the master page, and then add the following code after the </form> tag and before the </body> tag.
- In the new page layout that you created in step 1, add the following code to the end of the page.
This code enables the new page layout to reference the CorePreLoad.aspx page. All items on the page are displayed before the CorePreLoad.aspx file is loaded to perform its function.
- Check in the new page layout, and then publish it.
- Use the new page layout to create a new page.
When anonymous users browse the new page, the Core.js file does not have to be downloaded before the user can view the page or before the user can interact with the page.
For example, you use ArticleLeft.aspx to create a new page, and then you use ArticleLeftNoCore.aspx to create another new page. Although both new pages are identical, one new page references the Core.js file and the other new page does not.
- Test the new page that you created to make sure that all controls work correctly.
If controls do not work when anonymous users browse the page, remove the controls from the new page. Alternatively, remove the controls from the new page layout. The optimization in this procedure assumes that the new page does not require the Core.js file because no items on the page require the Core.js file.
- Make sure that the Core.js file still appears on other pages on the site. Browse other pages on the site to verify that the Core.js file appears on those pages.
To verify that the optimization in this procedure works correctly, browse the new page as an anonymous user, and then view the source code on the page. Confirm that a reference to the Core.js file does not exist. Then, view the cache. Confirm that the Core.js file is downloaded to the server. Only the page that you created from the new page layout does not reference the Core.js file. Other pages on the site will continue to reference the Core.js file.
For more information about this procedure, visit the following Microsoft Web site:
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure. However, they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
Article ID: 933823 - Last Review: May 15, 2007 - Revision: 1.2
- Microsoft Office SharePoint Server 2007
- Microsoft Office SharePoint Designer 2007
|kbhowto kbexpertiseinter kbinfo KB933823||