JavaScript injection in SharePoint Online - Office 365 Developer Patterns and Practices

Play JavaScript injection in SharePoint Online - Office 365 Developer Patterns and Practices
Sign in to queue


Andrew Connell walks through the Office 365 Patterns & Practices Scenario injecting JavaScript into SharePoint Online pages. This code can be found on GitHub here



Download this episode

The Discussion

  • User profile image

    Opening comments

  • User profile image

    This is just hilarious.... The amount of code AND showing how to do this in a provider hosted app :-)

    If the O365 service doesn't support adding a script tag to all pages without "bending over backwards" like this it is pretty sad.

  • User profile image

    It seems the code no longer exists under the filename listed.

  • User profile image

    I agree with Jonas, There is NO server side code allowed in Sharepoint Online (sharepoint hosted). Not helpful

  • User profile image

    Seems like source code has been moved to:

  • User profile image

    Guys, have anyone managed to run this example? I am getting Access Denied exception although the App has Full Control permissions on Web and Site levels.

  • User profile image
    Dr Doom

    "microsoft does not recommend creating custom master pages or customizing the default master page(...), the reason for this is that if the master page is customized a site collection will not get any fixes or new capabilities that are added to the platform by microsoft"

    are you kidding me? that is probably the main reason why people should create custom master pages. Whenever microsoft realeases "any fixes or new capabilities" they could end up ruining the functionality of my site, i'd rather have more control over when and what "new capabilities" are added.

  • User profile image
    Nitin Khubani

    Hi Guys,

    I have been following this tutorial and it has helped a lot! Great one!!!

    However facing issues with Mobile pages. So I have a JS which must run on all pages of SharePoint to have control of them. Now, I want it to be executed on mobile pages too but its not being injected to mobile pages because it seems they dont have master page.

    The URL format is like;


    Can anyone help me to get rid of this issue :(

  • User profile image

    I would like to see an official reference to where exactly Microsoft says creating a custom master page is not recommended.

  • User profile image
    YouMust BeKidding

    This horrific, Frankenstein coding -- for the Frankenstein kludge-fest called "SharePoint" -- just to add some JavaScript to every page is F-in insane.

    Show this to potential customers, and they should run screaming!

    Bury Sh1tPoint, once and for all!

  • User profile image

    I have a master page in SharePoint Online and would like to add a link below the search bar.
    This master page is at Site Collection level and all subsites inherit this master page.
    Now if I use the technique shown in this video then does my customization going to be applied in all subsites as well or just root site in the site collection.

  • User profile image

    Please notice that this video is from 2014 and completely outdated. We do recommend using SharePoint Framework as the extensibility model for SharePoint where possible. Please see the official documentation for more details at

  • User profile image

    Is this still a valid (recommended) approach to getting javascript into a SharePoint site/page for Office 365 SharePoint users? Some comments here suggest this is outdated but the content editor web part appears dead and gone and I see no other official-sounding means of getting javascript into SharePoint.

  • User profile image
    Chad Price

    I would hope so but I am fairly new to script

Add Your 2 Cents