3

I am building a master page for a public facing website, and I have removed core.js for better performance.

The issue is that I am now getting a bunch of errors because functions are absent. This includes for example Sys.Application.initialize(),ExecuteOrDelayUntilScriptLoaded() and WPSC.init().

How can I prevent these scripts from running? The page itself works fine, I just want to get rid of the errors.

Here is an live example: http://usermanagedsolutions.com

[Update]

Several comments were questioning the removal of core.js, and Shane Jordan replied with an excellent reference from Chris O'Brien:

http://www.sharepointnutsandbolts.com/2011/01/eliminating-large-js-files-to-optimize.html

Whether core.js should be removed is open to discussion, but we should at least consider the option. Chris show in his post that the gains can be significant. Regarding caching, the answer is also in Chris' post: for public sites, "we are primarily discussing the first-time user experience".

Thanks all for the input!

[Update 2]

To answer James' comment: I removed core.js for visitors only. Contributors get the full SharePoint functionalities.

3 Answers 3

3

I gave +1 to Marc, but thought I would offer the only alternatives I can think of:

  1. Try to extract the necessary functions from core.js and include them in a custom .js file (risky, could be time consuming)
  2. Don't use the SharePoint controls that are referencing core.js functions
4
  • to your point 2: fortunately for Microsoft, SharePoint has a lot more to offer than core.js ;-). Content management features (co-authoring, alerts, workflows, etc.) remain useful behind the scene.
    – Christophe
    Commented Jul 13, 2011 at 3:08
  • to your point 1: thanks, I was considering something similar (dummy functions). They are actually easy to identify with Firebug (follow the error messages). I am just hoping that there's a cleaner way.
    – Christophe
    Commented Jul 13, 2011 at 3:10
  • That makes sense I guess. Use SharePoint as the back-end system with your own UI. Instead of using dummy functions, I think you want to remove whatever control is causing those functions to be called.
    – Kit Menke
    Commented Jul 13, 2011 at 3:17
  • +1 Agree. Now, identifying the control is trickier than identifying the function...
    – Christophe
    Commented Jul 13, 2011 at 4:14
7

My question is why on earth you'd want to remove core.js. It contains JavaScript functions which are useful even in a public-facing situation, and that's why you are getting errors. These include dropdown menu items, page layout manipulation, expand/collapse behavior on list views, etc.

Remember that core.js will only be downloaded once per user when they first visit the site (unless they clear their browser cache). I can't see enough benefit from removing core.js to justify the headaches to get things to work without it.

5
  • simple answer: I don't need any of these on my public facing site. And you'll see that many public sites built on SharePoint don't use them either.
    – Christophe
    Commented Jul 12, 2011 at 17:53
  • Your audience might not need them, but what about your page authors?
    – James Love
    Commented Jul 12, 2011 at 18:12
  • 3
    Chris O'Brien has a post talking about the benefits of this practice. sharepointnutsandbolts.com/2011/01/…
    – Shane
    Commented Jul 12, 2011 at 20:04
  • @James: my Master Page has conditional sections. Authors get the full functionalities.
    – Christophe
    Commented Jul 13, 2011 at 3:05
  • @Shane Jordan: excellent reference! I'll add it to my original question.
    – Christophe
    Commented Jul 13, 2011 at 3:06
0

You might wanna consider removing all other *.js files as well as they might call functions from within core.js. Some files might be loaded through the "AdditionalPageHead"-Delegate - you could deactivate this as well. If there are still methods being called, you could overwrite those methods in your own *.js-file with dummy-methods.

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.