Should I use target _blank in href
2023-02-27Question
I was coding my Notion paragraph component to handle any href links, and wanted links to open in another browser. In the paste I always used target="_blank" but I recalled hearing in the past that this requires a second thought. What was it?!
Resolution
Apparently, if you link to another page using target="_blank" you actually expose your site to performance and security issues! [1] From Google, it quotes:
Well damn, that’s interesting. Out of curiosity I might have to try this out just to really see how that works.
Anyhow, the solution is to add rel="noopener" or rel="noreferrer" to the href tag when using _blank targets.
Thanks svelte-check
I looked this all up prior to writing the code and then I realized that in VS code it already is being linted and warning me of this issue with the resolution!
References
[1] https://developer.chrome.com/docs/lighthouse/best-practices/external-anchors-use-rel-noopener/