...from:
http://www.macworld.com/article/152101/2010/08/safariextensionshandson.html?lsrc=nl_mwweek_t_cbstories


Hands on with Safari extensions

The latest version of Safari (5.x), released earlier this summer, introduced a new extensions feature to Apple’s Web browser. Extensions allow you to alter the behavior of Safari through small, downloadable packages from by developers, created by using HTML, CSS and JavaScript.


Activating the extensions feature

Now that we’ve logged a few months of browsing with Safari 5, it’s time for a closer look at this feature: how to turn it on (if it isn't already), how to install and use extensions, how to update extensions, and how to troubleshoot issues with misbehaving extensions. Once you've gotten a handle on Safari extensions, take a look at some of our favorite extensions.

Starting with Safari 5.0.1, the Safari-extensions feature is enabled by default. Launch Safari 5.0.1, and extensions just work—you can skip to the next section to learn how to download and install them.

If, for whatever reason, you're still using Safari 5.0 and can't update yet, turning on the feature isn’t as obvious as you’d think. In fact, Apple has hidden the feature in Safari’s Develop menu…which is alsodisabled by default. So the process for turning on extensions requires a couple steps:

  1. In Safari’s Preferences window (Safari -> Preferences), switch to the Advanced pane, and then check the box to Show Develop Menu In Menu Bar.
  2. In the new Develop menu that appears in the menu bar (between Bookmarks and Window), choose Enable Extensions.

Once you’ve used the Enable Extensions command, you can uncheck the Show Develop Menu In Menu Bar setting to regain that valuable menu-bar space.

Installing extensions

With the extensions feature activated, Safari’s Preferences window sports a new Extensions pane that lists all installed extensions and lets you customize the behavior of each. This screen also lets you disable and enable individual extensions or turn off the extensions feature altogether—useful when troubleshooting (more on that below).

So how do you get extensions? With the release of Safari 5.0.1, Apple introduced the Safari Extensions Gallery, a curated collection of third-party extensions Apple has chosen to showcase—you can even access the Gallery right from the Safari menu. Divided into categories such as News, Social Networking, Security, and Productivity, the Gallery currently contains more than 100 extensions, each with a short description, a link to the developer's site, and an Install Now button. (If you haven't updated to Safari 5.0.1, you won't see these Install Now buttons.) Click the Install Now button for an extension, and in a second or two the button will change to an Installed graphic indicating that the extension has been installed.

But there are plenty more Safari extensions out there that don't appear in the official Gallery. Some you'll find while browsing the Web, but perhaps the best alternative source for extensions right now is the Safari Extensions blog, which has been publishing info about newly available extensions since Safari 5.0 was released. I recommend subscribing to the blog's RSS feed so you can keep an eye out for useful new extensions as they're released.

However, extensions you download outside of the official Gallery require a different installation procedure—they don't install automatically. The Website hosting the extension will provide a standard download link, and then Safari will download the extension—a file (actually a Mac OS X package) ending in .safariextz. (If, instead of downloading a .safariextz file, Safari displays a window of ugly code, click the Back button and either Option-click the download link or right-click—or Control-click—on the link and choose Download Linked File.) Depending on how you’ve configured Safari to handle downloaded files, Safari may immediately ask you if you want to install the new extension. If not, find the newly downloaded file package in the Finder and double-click it to view the same Don’t Install/Install dialog. Read the official warning text, click Install, and the extension is installed.

(In case you're wondering why a third-party extension isn't included in Apple's Gallery, there are a couple possible reasons. The first is simply that the developer hasn't submitted it to Apple for possible inclusion. The second is that the developer has submitted the extension and either Apple hasn't yet approved it or has rejected it for some reason. This doesn't mean you shouldn't install extensions that don't appear in Apple's Gallery, but you should be a bit more careful before doing so.)



Safari's Preferences window sports a new view when extensions are turned on.

Whichever method you use to install extensions—Apple's Gallery or manual download and install—installed extensions are stored in ~/Library/Safari/Extensions and appear in the new Extensions screen of Safari's preferences window. For some extensions, the new features they provide are immediately available—no restart or other action is required. In fact, if the extension uses a toolbar button, that button may automatically be added to Safari’s toolbar without any further action from you. (If it isn’t, just choose View -> Customize Toolbar and then manually add the toolbar button.) However, I've found that most extensions work only on new tabs you open after installing the extension—you won't get the new features on existing tabs. (This is often the case even if the extension has automatically added a toolbar button to Safari—the button won't do anything when viewing existing tabs.)

Using and managing extensions

As mentioned above, many Safari extensions function as new buttons for Safari’s toolbar. For example, Ars Technica and Macworld contributor John Siracusa’s Reload Button restores the Reload button found in Safari 3 and earlier, and Clint Ecker’s Short URL adds a new button that automatically shortens, using either is.gd or bit.ly, the current tab’s URL. You use these toolbar buttons just like any other: click the button to access the simple feature.

Other extensions add new commands to Safari’s contextual menus: right-click somewhere on a Web page, and you’ll see the new options. For example, Shortenz Linkz lets you right-click on any URL link on a Web page to generate a shortened URL using the URL-shortening service of your choice. It also provides an option to send the URL in a Twitter message.

But many Safari extensions work in the background, doing their thing without any effort on your part. For example, there are already extensions that automatically reformat YouTube pages or Google Reader’s interface for easier viewing, that add additional options to specific Web pages, or that disable JavaScript elements hosted by particular servers.

If an extension provides settings to customize its behavior, you’ll find those settings in the Extensions pane of Safari’s Preferences window. Select the extension in the list on the left, and that extension’s options appear to the right.

If you decide you don't like a particular extension's feature(s), you can disable it. Just select it in the list of installed extensions and then uncheck the Enable [extension name] box. Alternatively, you can uninstall it, as explained below.

Updating extensions

Like other software, Safari extensions are updated to fix bugs and add new features. This is especially true right now, as developers are still learning how to create and perfect extensions. Thankfully, Safari provides a built-in mechanism for checking for, and updating to, new versions of extensions.

Open the Extensions pane of Safari Preferences, and click the Updates item in the lower-left corner. To the right, you’ll see a list of any extensions for which newer versions are available. Click an individual Update button to update that extension—the new version is downloaded and installed. Alternatively, click Update All to install all pending updates with a single click.

To avoid having to manually check for available updates, you can check the box to Install Updates Automatically. This configures Safari to automatically download and install updates whenever they’re available. Given how frequently extensions are being updated these days, this is a welcome option, although it’s not yet clear how often Safari checks for new versions of installed extensions.

Troubleshooting extensions

Depending on which extensions you choose to install, the neat features you gain may come with a price: Safari crashes. Between the release of Safari 4 a year ago and the release of Safari 5 in June, I had very few problems with Safari; in the first couple weeks after installing Safari 5.0 and testing extensions, I had literally dozens of crashes, and I was able to trace nearly all of them back to issues with extensions. (Unfortunately, unlike the Safari 4-and-later feature that lets Safari plug-ins crash without taking down the entire browser, an extension problem often crashes Safari outright.)

I've personally had the worst luck with extensions that aim to block specific JavaScript hosts that alter the behavior of sites. For example, several extensions block JavaScript from intellitxt.com in order to let you avoid those annoying ads that pop up on Web pages when you mouse over words. Unfortunately, whenever I’ve had one of these extensions installed and active, Safari would crash regularly.

I also occasionally experience a problem where simply disabling a particular extension, by turning off that extension in the Extensions screen of Safari Preferences, crashes Safari. This seems to be especially common when disabling an extension that use a toolbar button. In many cases, I've been able to avoid such crashes by manually removing the extension’s toolbar button (using Safari's Customize Toolbar screen) and then disabling the extension.

Thankfully, over the past couple months, I've found that Safari's stability has improved dramatically when using extensions. I suspect the biggest reason is that extensions developers have been improving their extension-coding skills, but it's also possible that Safari 5.0.1 included some extensions-handling improvements of its own. Whatever the combination, using extensions seems to be notably safer—in terms of browser stability—these days than when the feature first debuted. That being said, extensions can still cause problems with Safari, so it's good to know some basic troubleshooting procedures.

If you know which extension is causing a problem, you’ve got two options: The first is to simply disable that extension (as explained above) and then wait for an update to see if a new version fixes the problem. The second is to remove the extension completely. To do this, select the extension in Safari Preferences and then click the Uninstall button that appears to the right.

What if you don’t know which extension is causing a problem? Remember the “classic” Mac OS extension conflict? Welcome back, old friend. It’s time to do some conflict testing.

The first step is to turn off Safari extensions completely: Open the Extensions screen of Safari Preferences and move the main slider to the Off position. Then browse the sites that were open the last time Safari crashed or exhibited otherwise troublesome behavior—Safari’s Reopen All Windows From Last Session command (in the History menu) is great for this. If the problem still occurs, you know extensions aren’t the cause.

If the problem is gone, at least one of your extensions is to blame. Turn the main extensions slider back to On, then scroll through the list of installed extensions in Safari Preferences, noting which ones are currently enabled. Then disable one and reload your last session. If the problem occurs again, the extension you disabled is likely not the cause. Disable the next suspect and reload the last session again. Is the problem gone? You’ll want to repeat this process until disabling an extension fixes the problem—that extension is likely the cause.

Of course, just as with classic Mac OS extension conflicts, it’s possible that a combination of Safari extensions is the real issue, but I haven't yet come across such an issue (and uncovering such combinations is the topic for another article…).

Use it wisely

As you browse Apple's Gallery and the Web for useful extensions, keep in mind that the more extensions you install, the more you increase the chance of problems. But just as important is that you increase the complexity of the browser itself—more toolbar buttons, more keyboard shortcuts, more contextual-menu commands, and more ways in which the content on Websites is tweaked or otherwise affected. So use extensions judiciously. Despite downloading and testing scores of extensions, I've kept only a couple dozen installed, and only a few of those are currently active. Nevertheless, Extensions has become one of my favorite new Safari features in years.