Links That Open in New Processes

Friday, December 04, 2009

Labels: ,

We've introduced a new way for web developers to take advantage of Google Chrome's multi-process architecture, as of version 4.0.229.1. Google Chrome already uses separate OS processes to isolate independent tabs from each other in the browser, so that crashes or slowdowns in one tab won't affect the others. Google Chrome even switches a given tab's process if you type a different site's URL into the Omnibox.

In many cases, though, Google Chrome needs to keep pages from related tabs in the same process, since they may access each other's contents using JavaScript code. For example, clicking links that open in a new window will generally cause the new and old pages to share a process.

In practice, web developers may find situations where they would like links to other pages to open in a separate process. As one example, links from messages in your webmail client would be nice to isolate from the webmail client itself. This is easy to achieve now, thanks to new support in WebKit for HTML5's "noreferrer" link relation.

To cause a link to open in a separate process from your web page, just add rel="noreferrer" and target="_blank" as attributes to the <a> tag, and then point it at a URL on a different domain name. For example:

<a href="http://www.google.com" rel="noreferrer" target="_blank">Google</a>

In this case, Google Chrome knows that the page will be opened in a new window, that no referrer information will be passed to the new page, and that the window.opener value will be null in the new page. As a result, the two pages cannot script each other, so Chrome can load them in separate processes. Google Chrome will still keep same-site pages in the same process, to allow them to share caches and minimize overhead.

We hope you find this useful on your own sites!

8 comments:

randall said...

Cool! Will we ever see a "noopener" that doesn't pass window.opener and starts a new renderer process, but still passes Referer? I can imagine that being useful on, say, a search results page opening links in new windows -- the search engine doesn't necessarily want to hide that it's the referrer, but it's handy for the browser to know it's free to use a new renderer or not as it sees fit.

POWRSURG said...

I've always assumed that rel was only meant for a single value, but this post made me think that there may be occasions where you want to pass in multiple values to the rel attribute. I can't find anything that specifically mentions whether or not that multiple values are legal or illegal. Can you for instance pass in rel="noreferrer nofollow"?

Dying said...

So, if you want it to open in a different process, you also must lose the referrer? that is just not cool.
+1 @randall.

@POWERSURG - I believe you can, it should work on the same principle as "@class".

啄木鸟 said...

good

Randall said...

One use case where this would make a lot of sense, though without the "opening things into new windows" component, is Google Reader. I can't tell you how many times I've opened up 25 or 30 blog links from my Google Reader tab, only to have each and every one of them crash because one of them's taking too long to load. I'd rather take the burden of them all having separate tabs than having everything crash.

Dan said...

Hi, I'm really curious on how does Chrome start up(cold) so fast compare to, heck, anything else, on my XP machine. I suppose this have to do with the upcoming topic on responsiveness of UI. I can't wait for you guys to enlighten me!

night-fairy-tales said...

It`s amazing!

ventura said...

Randall, I thought I was alone in this! Google Reader crashed a lot over here when I opened too many blog links from it. All tabs would open inside the same process, like a bubble inflating, and when I ran out of memory the bubble would burst — and I got "sad tabs".

Now I don't have this kind of problem anymore: instead of middle-clicking to open a new link, I right-click and click on "Open in a new tab". WebKit has a faulty implementation of middle-click, which causes too many tabs to open inside the same process (issues 244 and 255).

Also, to ensure every tab is opened in a new process, I put the command "--process-per-tab" in the Chrome shortcut. More about that here.