Redirecting Mobile Visitors Instantly

Hi everyone looking for some help here, I’m really new to code and can’t figure out how to do what I want without breaking everything.

So essentially I followed this article (https://support.wix.com/en/article/velo-tutorial-redirecting-mobile-visitors) on how to re-direct visitors to a separately designed home page if they are on a mobile device when my site first loads.

In the article it shows you how to set this up, however the issue is there is a time delay. Now I’m smart enough to have figured out I can reduce the default 7500 nanoseconds delay in the example code they provide to a simple 0 to reduce this delay, but there’s still a 1 or so second delay before the re-direct command executes. Now I believe this has to do with the part of the code that waits until all elements on the current page have loaded before executing the code, which I’ve pasted below:

$w.onReady( function () {

Now I want it to just happen instantly so you basically never see the initial page load before the re-direct takes place, but I’m not sure what to replace this with, as simply removing it breaks the command completely.

Screenshot of my current code setup below, Any help would be appreciated!

Anyone got any advise on this?

Perhaps you can hide all your ELEMENTS on the INITIAL-PAGE.
And show all needed elements when page has loaded.

1 Like

@russian-dima that’s a good idea, guess it’ll have to be my work around for now :slight_smile:

@williamsa09 You can also vote for this feature request here and add your own comments: https://www.wix.com/velo/requested-feature/corvid-api-to-force-desktop-or-mobile-view-to-user

If you go for Velo-Ninja’s solution , you will have an issue that you should take into consideration.
If members click “Forget password” they get redirected to the real homepage with a special URL query parameters that pops up the “Forget password” modal.
If you redirect from the homepage to another page, members will not be able to restore their password on mobile devices.
So you have to add a condition to your code, that if the url contains: “password” - do not redirect.

or maybe " P assword" I don’t remember , you should check it.

I don’t have a member’s area on my site or any kind of user account functionality on my site, so this isn’t a concern. Thanks though!

@marlowe-shaeffer Hi there, having looked at it that request seems a little different to what I’m looking for. I just want a way to make my site automatically re-direct users to a different home page if they are on mobile, since I have two totally different layout designs for mobile and desktop. I currently have it setup, but there’s a delay.