J
J
John Johnson2019-11-21 21:18:16
JavaScript
John Johnson, 2019-11-21 21:18:16

How to make a quick redirect?

Hello, tell me there is a script that reads the Url and looks at the parameters in the url, if they are not there, then you need to redirect.
The usual methods Location / href, meta refresh are slow, that is, the page has time to load, partially.
Is there any way to do this instantly? that is, also go through the url, make a check and redirect, if necessary, to a third-party portal, but so that it is many times faster.
Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
Zolg, 2019-11-21
@Zolg

The usual Location ... methods are slow, that is, the page has time to load, partially

Well, what to do, life is like that.
True, nginx location processes not only before the page is returned, but even before deciding how and where to return it. But who cares?

A
abberati, 2019-11-21
@abberati

They are not slow. The point is where the code that will cause the redirect is located. If it is at the end of the page, then before the code is executed, the page will first (suddenly) be rendered, and then a redirect will occur. If the script is in the head, then the body of the page will not have time to render before the redirect. Read the DOM tutorial.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question