Archive for the ‘Backend’ Category

File Under: Backend, Web Services

New Asynchronous Script Stops Google Analytics From Slowing Down Your Site

Google Analytics is one of the more popular ways to keep track of your site’s visitors. With the ability to track, compare and compile all sorts of statistics about who’s visiting your site, Google Analytics is hard to beat.

Unfortunately, all that statistical goodness has a price — the JavaScript Google Analytics uses to track your visitors can slow down your page load times. Traditionally, the delayed page load problem was solved by placing the Google Analytics JavaScript code at the bottom of your pages (just before the closing </body> tag).

However, Google is now offering a second possible solution — a new Google Analytics script that loads asynchronously.

The asynchronous script means browsers will load the ga.js script file separately from the rest of your page, minimizing the impact on page rendering.

The net result is that you can move your Analytics code back up to the head tags of your pages and it won’t slow down your pages. Or rather it will, but it won’t be noticeable to users. In our testing, the new script loaded in between 80ms-120ms, whereas the old script loaded in 40ms-60ms.

The new script is definitely slower, but because it loads separately from the rest of your code visitors will see all your content before the new script kicks in, even if it’s at the top of the page.

In our testing, the overall page load time for the new script in the head tags was almost exactly the same as for the old script at the bottom of your page.

So why would you want to switch to the new script? The primary reason is that some advanced features of Google Analytics, like JavaScript event tracking, require the script to be embedded in the page’s head tags. If you’ve been wanting to use any of the customization and advanced features that require Google Analytics’ code to reside in the page header, but haven’t wanted to sacrifice page load times to get it, well, now you have your solution.

The new script and some new embed code can be found on Google Code. Keep in mind that the new script is still a beta, which means you might want to hold off using it on production sites.

See Also:

File Under: Backend, servers, Web Basics

Move Over, HTTP. Say ‘Hello World’ to SPDY

Google plans to introduce a new protocol for web transactions it says is more than 50 percent faster than HTTP.

A post on Google’s Chromium blog describes the new protocol, SPDY, pronounced “Speedy”:

SPDY is at its core an application-layer protocol for transporting content over the web. It is designed specifically for minimizing latency through features such as multiplexed streams, request prioritization and HTTP header compression.

The Chromium team, which is in charge of developing the Chrome browser and its associated technologies, reports that SPDY has been able to load web pages 55 percent faster than the HTTP protocol in lab conditions using simulated home-network connections. The team says its goal is to make SPDY eventually run twice as fast as HTTP.

HTTP is the language currently used by servers and browsers for the vast majority of common tasks on the web. When you request a web page or a file from a server, chances are your browser sends that request using HTTP. The server answers using HTTP, too. This is why “http” appears at the beginning of most web addresses.

So, Google’s proposal would involve rewriting the web’s most commonly used and baked-in transaction method.

“HTTP has served the web incredibly well,” the post’s authors write. “We want to continue building on the web’s tradition of experimentation and optimization, to further support the evolution of websites and browsers.”

If such a massive shift were to ever take place (and nobody’s promising it will at this point), it would require a whole lot of buy-in from outside Google. To that end, the company is releasing its early-stage documentation and code for SPDY along with a call for feedback.

It may seem like a brash move, but the Chromium team seems to enjoy ruffling feathers. In September, the same group released the Chrome Frame plug-in for Internet Explorer which essentially embeds Google’s browser inside Microsoft’s, giving the ability to render websites that IE wouldn’t normally be able to handle.

To contribute to the SPDY discussion, visit the Chromium Google Group.

Image: Warner Brothers

See Also: