Close tabs to the right for Safari

Chrome has a terrific feature that lets you close all the tabs to the right of the current one. Very handy if you’ve opened a bunch of links from search results, found the one you want, and want to get rid of all the rest. Safari is a bit more limited; you can only close all but the current tab. You can get around that via Applescript.

First, make sure “Show Script menu in menu bar” is checked in the Applescript Editor preferences. Enter the following script into Applescript Editor, and save it to ~/Library/Scripts/Applications/Safari.

tell window 1 of application "Safari"
    close (tabs where index > (get index of current tab))
end

If you wanted to be able to assign a keyboard shortcut for this, you can turn the script into a service using ThisService, and assign the shortcut in the Keyboard Preferences Pane.

(via Ask Different)

Use DNS prefetching to speed up web font loading

Poking around in a framework today, I saw they’d suggested using the new dns-prefetching feature in HTML5 to speed up resolving some foreign domains. Further digging showed folks are prefetching the domains from which Google serve their web fonts. It’s a great idea, given that web fonts are one of the biggest contributors to page weight on a largely text web site.

To include prefetching of the Google web fonts domains in your page, add the following code to your head:

<link rel="dns-prefetch" href="//themes.googleusercontent.com">
<link rel="dns-prefetch" href="//fonts.googleapis.com">