RequireJS Arrives in SharePoint Online Build 16.0.4230.1217 (Or Earlier?)

A JAVASCRIPT MODULE LOADEREver watchful – and talented – guy that he is, my friend Paul Tavares (@paul_tavares) pinged me the other day on Twitter with a question.

Hey. Question. On your O365, did you add RequireJS as a SOD? Noticed it was registered when I looked at the page code the other day.

Paul has a Site Collection in my tenant that we share for R&D and I certainly hadn’t done anything, so we went back and forth on it a bit.

If you do a View Source on a SharePoint Online page, you may well see this line:

<script type="text/javascript">RegisterSod("require.js", "https:\u002f\u002fcdn.sharepointonline.com\u002f16148\u002f_layouts\u002f15\u002f16.0.4230.1217\u002frequire.js");</script>

This tells me that my tenant is on build 16.0.4230.1217. It’s on First Release, so it may be ahead of the build you see in your own tenant.

The net-net of that line is to load RequireJS if it is needed using SharePoint’s SOD (Script On Demand) framework. It’s a little funny to me that this is happening, because RequireJS’s primary purpose in life is to help load script files when they are needed (among other things).

The good thing here is that if you want to use RequireJS in your applications – as I am regularly now – it’s already there for you by default – in SharePoint Online, at least. Paul and I have no idea when it showed up, but it’s a good thing. The Microsofties ought to let us know when they add such a useful library!

Similar Posts

8 Comments

  1. Thanks for sharing this Marc. You have hawk eyes ;-)

    We are currently doing this as an experiment in SharePoint Online for one of our engineering teams. This is considered a preview feature that we’ve rolled out and therefore DO NOT recommend that you leverage this library in your own code on the page client-side. The reason we state this right now, is because as an experiment we may choose to pull this from SharePoint Online. If you take a dependency on this *if* we did pull it, naturally that would break your code.
    Our engineering teams are investigating how we can better leverage open source libraries to accelerate our development process on our products. You would have noticed various other areas leveraging libraries such as the Video Portal.

    We will communicate in the future stronger guidance on what we recommend you can leverage that we have on the page. With the news of Jeff Teper being back on board, there will be a bunch of news around a strategy we will be able to share hopefully late September once he’s settled in.

    1. Paul’s the hawk-eyed one; I’m the typist.

      That phrase “take a dependency” always makes me giggle a little. I was told not to “take a dependency” on the markup in forms, and 6 years later…

      I look forward to hearing the “bunch of news around a strategy [you] will be able to share hopefully late September once he’s settled in”. I can’t count the equivocations in that sentence!

      M.

    2. Thanks for the response Jeremy. I like the fact that MS is looking into the use of already available open source libraries. Specially those that have pretty much have become the “standard”.

  2. I don’t get this move. So a year or two ago MSFT added “require / define” to the global scope which broke anything that used require.js, now they add it. However it’s a curious move as to why they aren’t adding SystemJS when that can address require.js as well… I wonder what’s using it…

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.