Photo by Shahadat Rahman on Unsplash

How to fix target=”_blank” links: a security and performance issue in web pages

Ali Kamalizade
Sedeo

--

Almost every web page has links which open in a new tab leaving the other web page still available. For example, news agencies will tweet about recent events on Twitter: the tweet contains a short description of the article and a link to see the full story on their web page.

By default, links in HTML are opened in your current tab and this is usually helpful. After all, as a web page owner, you want people to stay on your web page and not get distracted by too many open tabs or other web pages. People’s attention is limited which is why you want them to focus on your content. Besides, links which open in a new tab are also bad for accessibility if you don’t provide hints and ARIA attributes.

There are still cases where you want or need to link to external pages. The aforementioned news agency example is a good example: news agencies want people to read news articles on their web pages and not on external web pages like Twitter because you need the ad revenue from visitors. This is why Twitter allows its users to use links in their tweets. Usually, opening links in a new tab is used when the link does not belong to you but to a third party.

Not a paying Medium member? Click here to read the story with a free account ⬇️

--

--

Ali Kamalizade
Sedeo

Co-founder of Sunhat. Posts about software engineering, startups and anything else. 有難うございます。🚀