Skip to main content

Posts

Showing posts from January, 2019

How to Fix: Links to cross-origin destinations are unsafe

Why is "Links to cross-origin destinations are unsafe" an issue? When you open another page using target="_blank", the other page may run on the same process as your page, unless "Site Isolation" is enabled. If the other page is running a lot of JavaScript, your page's performance may also suffer. Aside from that, the other page can access your window object with the window.opener property. This exposes an attack surface because the other page can potentially redirect your page to a malicious URL. So, if you have links to another origin and you use target="_blank", always add rel="noopener" or rel="noreferrer". rel="noopener" - This indicates that any newly created browsing context which results from following the hyperlink will be disowned, which means that its window.opener attribute will be null. i.e. <a href="..." target="_blank" rel="noopener">...</a> r

How to Fix: Uses Passive Event Listeners to Improve Scrolling Performance

When you encounter "Uses Passive Event Listeners to Improve Scrolling Performance" as a metric to be improved under "Best Practices" on Google Chrome Inspect Audits, add the code below after the opening body tag: <script type="text/javascript"> jQuery.event.special.touchstart = {   setup: function( _, ns, handle ){     if ( ns.includes("noPreventDefault") ) {       this.addEventListener("touchstart", handle, { passive: false });     } else {       this.addEventListener("touchstart", handle, { passive: true });     }   } }; </script> Setting the passive option on your touch and wheel event listeners can improve scrolling performance. If you are using a DIVI web theme, go to Theme Options , then the " Integration " tab, and add code to the <body> section.