I'm trying to add some JavaScript code to my o365 site which should be called everytime when the site is rendered and all the needed objects are initialized. So far I got to this, but still it doesn't work everytime:

<script type="text/javascript">
function theFunction()
if (document.getElementById("suiteBrandingIcon") != undefined)
// stuff, needed stuiteBradning icon

I added this strange ExecuteAndRegisterBeginEndFunctions to render the site also after the Sharepoint ajaxdelta is called. I'm adding this code at the end of the masterpage before the body end tag.

Is there any sharepointOnRender handler or anything similar?

1 Answer 1


Here are some options to do that: 1) Script on Demand: (load a js file then execute my code.)

function stuffThatRequiresSP_JS(){
    //your code


2) Delay until loaded (wait for a js file, then run)

function stuffToRunAfterSP_JS(){
    //your code

ExecuteOrDelayUntilScriptLoaded(stuffToRunAfterSP_JS, "sp.js")

3) load after other stuff finishes

function runAfterEverythingElse(){
    // your code



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.