How do I redirect to a site collection in SPO without ANY lag? The root https://******.sharepoint.com now has a simple javascript redirect: window.location.href = 'https://******.sharepoint.com/sites/home';

The problem is there a delay. Even placing a redirect in the <meta> head area and setting it to zero still has a lag in the redirect:

    <meta HTTP-EQUIV=”REFRESH” content=”0”; url=”https://******.sharepoint.com/sites/Home”>
<meta http-equiv="refresh" content="0; ,URL=https://******.sharepoint.com/sites/Home">
<meta http-equiv="refresh" content="0;URL='https://******.sharepoint.com/sites/Home'" />

this might be of interest: immediate redirect IIS

The only other way I know to avoid a lag in the redirect is a Powershell script.

#Connect to the SharePoint Online Site
$Username = "Anupam.Shrivastava@mytenant.onmicrosoft.com"
$Password = Read-Host -Prompt "Please enter your password" -AsSecureString
$Site = "https://myteant.sharepoint.com/sites/SC2"
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($Site)
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username,$Password)
$Context.Credentials = $Creds
#Update the welcome page
$web = $Context.Web
$rootFolder = $web.RootFolder; 
$rootFolder.WelcomePage = "SitePages/New Home.aspx";

This was not working well because I made a modern page off the root classic site. I input a SPFX web part that loaded JS. This is too many moving parts...

An effective way to do this is to create a classic page. I created a web part classic page and placed the JavaScript in the top of the page. I found that the issue is the modern pages. The load time is much better for classic pages.

Make the homepage a classic page with window.location.href = 'https://******.sharepoint.com/sites/home'; and it should work fine.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.