July 2007 Archives

  1. Jul19

    WordCamp 2007 kickoff dinner

    WordCamp kickoff party 2006

    WordCamp 2007 takes place this weekend in San Francisco. Almost 400 WordPress users and developers from all over the world are coming together for two-days of personal publishing workshops. I'm hosting a WordCamp kickoff dinner tomorrow night starting at 6:30 p.m. at Taylor's Automatic Refresher at the Ferry Building. It's our second-annual WordCamp kickoff dinner welcoming visitors from out of town with burgers, beer, and blogs along the San Francisco waterfront.

    Taylor's Refresher is a small business from the Napa Valley that takes advantage of some of the great food combinations the Bay area has to offer. Each attendee will be able to place individual orders with an expected bill between $10-$15 depending on splurge factors such as sweet potato fries, milkshakes, and beer. We'll have a sizable group sitting outside at the long picnic tables (pictured above) cooling off after what should be a pretty warm day. BART and Muni trains stop about a block away at the Embarcadero Station.

    (photo above taken by Scott Beale's camera tentacle during last year's dinner.)

  2. Jul17

    Scaling Google Gadget content

    Google spends hundreds of millions of dollars building efficient web serving infrastructure spread throughout the globe. Widget developers can take advantage of this optimized infrastructure to serve widgets quickly to one or a million users. In my last post I discussed best practices for scaling web widget content based on existing browser and Internet technologies. In this post I'll outline different ways you can take advantage of Google's architecture to serve your widget content to the world. I'll cover various depths of integration and their branding and licensing issues.

    1. Google widget hosting
    2. Caching remote content
    3. Summary

    Hosting your widget content on Google

    Google not only serves widget content in its personalized homepage and desktop products, it's also a web host.

    Google Gadgets Editor

    The Google Gadgets Editor helps developers build and test new gadgets inside their browser window. Once you are happy with the test results you can save and publish your gadget manifest file directly onto the "google.com" domain.

    The Gadgets Editor only saves XML files. Developers with external resources such as images, Flash, or movies, will need to serve those files using a different hosting option.

    Google Page Creator

    Google Page Creator logo

    Anyone with a Google account can create new web pages and upload files to their Google Page Creator account. Standard Google accounts can choose their own subdomain at "googlepages.com" and Google Apps customers can add pages and files under their own custom domain.

    Add a new site subdomain such as "widgets.example.com" or sign-up for an entirely new domain such as "examplewidgets.com" on the Google Apps website. All of your new content uploaded to Google Pages will be served from Google's infrastructure under the name you choose.

    Google Code Project Hosting

    Google hosts projects licensed under an Apache, Artistic, BSD, GPL, GLPL, MIT, or Mozilla open-source license. Google Code Project Hosting manages project collaborations on wikis, bug lists, and version control systems to help your users report issues with their widget or contribute new patches.

    If you're willing to open up your widget licensing and receive built-in community features Google Code Project Hosting may be the right widget hosting platform for you.

    Caching remote content

    Google caches your widget manifest file for quick response times and can cache even more files with the proper JavaScript calls. The core Google Gadgets library can cache your data sources, images, and any other form of remote content you choose.

    Remote data

    External data requests have an optional parameter, refreshInterval, that can override Google's default caching behaviors for all supported widget update data formats. You might lower your refresh interval to 15 to pull updates from a frequently changing data set or extend your refresh to 3600 for content that updates once per week.

    Remote images

    Google Gadgets has special handlers for caching and retrieving image files. The _IG_GetImage method constructs an img element for any URL for quick insertion into any DOM. The _IG_GetImageUrl replaces your typical src attribute with the appropriate location of a cached image on Google's servers.

    Cache anything

    Google will cache any URL specified in your code using the _IG_GetCachedUrl method. If you use external CSS, JavaScript, or Flash files you should pass each URL through the caching method to save your server some strain.

    Track statistics

    Cached content does not hit your server log files and therefore will not reflect the true use of your widget. Modern analytics tools have adjusted to the new forms of pageviews presented by heavy JavaScript and Flash utilization and your own measurement software should be able to plug-in to this new reporting style.

    Google Analytics customers can track widget pageviews using their existing software and accounts. You can create a new Analytics profile for each new widget or integrate reporting with your existing website, it's up to you.

    You need to require the Google Analytics library in your gadget manifest to load the appropriate libraries. You can then log new page requests using the _IG_Analytics method, a passthrough for the urchinTracker method found in the traditional Google Analytics and Urchin code. You can assign unique page names to each gadget action to track popular activities and use cases.

    Summary

    Popular widget content has the potential to melt your servers but the right code and planning can offload a lot of that burden onto Google's server farms. Your content will appear on each widget user's screen faster and with higher availability than you might be able to offer on your own servers. External free hosting and caching also helps you experiment without the fear you might crash your existing boxes.

  3. Jul17

    Optimize and scale web widget performance

    Serving widget content across hundreds of thousands of users per day is no easy task. A relatively small widget contains images, dynamic data, dynamic renderers, and manifest code that may consume 50 KB of space if you're lucky. That's 12 GB of bandwidth a day if you're lucky enough to hit 250,000 gadget views hitting your servers, or about 3 file bundle requests per second. Even Google's infrastructure has strained under the load of widget serving, but your sites don't have to suffer the same fate.

    In this post I'll provide tips and tricks for widget developers interested in serving fast, reliable widget content to as many people as possible. I'll highlight some of the best practices for serving web content and their specific application towards widget development. Your milage may vary. Please consult your operations professional before taking any magic pills.

    1. Browser and HTTP best practices still apply
    2. Reduce total network requests
    3. Reduce total request sources
    4. Speed of light still applies
    5. Cache
    6. Minify
    7. Draw frames
    8. Test
    9. Summary

    Browser and HTTP best practices still apply

    Your widget code relies on an integrated web browser and Internet connection to retrieve and display relevant content to your users. Placing your content within a smaller browser window or as a subsection of someone else's does not change the fact that your code executes locally within a browser or its plugins and requests resources from one or more domains on the Internet.

    Reduce total network requests

    Scripts and CSS can be stored directly within your Google Gadget manifest file. Placing all your infrequently changing content in a single file reduces the amount of network connections created by your web browser and lets it focus on taking one big bite instead of multiple small bites.

    Typical web development best practice is to separate CSS and JavaScript into separate files because the HTML content will change much more frequently than your styling and interaction code. Individual widgets are so tightly integrated it makes more sense to bundle the resources and serve it up as one package with each release. Developers may want to separate their resources during the development stage and execute a packaging script during the deploy stage.

    Reduce total request sources

    Retrieving a new piece of data requires both a file and a location. On the Internet we take a few relatively quick steps to help connect a series of letters and numbers to a unique position on a hard drive platter in a specific remote machine.

    1. I would like example.com/widget.xml please.
    2. A domain lookup occurs. Where is example.com located? How may I send laser beams closer to its location?
    3. Oh, you want the 2nd server on the 3rd rack on the 4th floor of this DataBank facility in Dallas. Sprint will take you there.
    4. Server software running on specialized hardware returns widget.xml to the requester.

    If you don't need to ask for the location of example.com you can skip a step and not perform what is called a DNS lookup. Each DNS record is stored by your local system(s) for a set period of time. Domains that distribute the load of user requests across multiple machines and appreciate quick fail-over ask domain servers to forget everything they just learned within minutes. Sites with a small set of servers that do not change location often might ask domain servers to update their location within hours or days.

    Longer time between domain record updates shortens the steps needed to accurately serve your site's content. You should evaluate your server configuration and IP pool to determine what frequency of updates best matches your Internet behavior.

    Each sub-domain is treated as its own domain entry so the same rules apply. Your widgets.example.com site might be served from Boston by one provider while example.com is served in Dallas by another provider. Each new domain address adds some weight to your total page load.

    Think globally, serve locally

    The fastest server hardware and software is still limited by the laws of physics. Requests and their responses need to travel over twisted copper wires, fiber optics, and other modes of transport to connect a remote server and a local desktop. A customer in San Francisco receives data from Los Angeles faster than he will receive data from Atlanta. A fiber optic laser beam covers 400 miles quicker than it can cover 3000 miles, with typically less rest stops along the way.

    Some companies work around this issue with content delivery network (CDN). A CDN optimizes each incoming request based on the requester's location. Someone requesting your widget from Jacksonville might receive the file from servers in Atlanta while a user requesting the same data from San Diego might receive his file from Los Angeles. Akamai, Limelight Networks, and CacheFly are just a few of the delivery networks in the United States. Prices and performance vary but a CDN can help you conquer the speed of light.

    Old vs. new

    Web browsers load content into local memory and storage before displaying new content on your screen. Each time you load a widget and its resources the web browser will check for locally stored up-to-date copies of each file described on the page before downloading a new copy from your server. Like the milk in your fridge, each file should have an expiration label to help tools interacting with your content when it's time to throw out the old stuff and get a new copy. If your widget references a file that has not expired from local storage your content loads a lot quicker than if it had to visit a remote server.

    Minimized content

    Adding spaces and new lines helps humans view source and author new content. While easy on the eyes, your formatting adds extra information to each file and takes up more space than necessary. The machine does not care about your CSS and JavaScript indentation habits and comments.

    You should "minify" all content before publishing your widget. Tools such as JSMin and Dojo ShrinkSafe are two tools you can add to your publishing process to automatically process files for full minification.

    Properly frame content

    A web browser progressively loads a page on your screen to combine text, photos, sub-pages, and plugin content into a single browser window. You can help speed up the process by including extra properties in your widget code on any piece of content a browser might need revisit.

    Images (img) and objects should have a defined height and width. This extra data lets browsers draw a box where the content will later be inserted instead of waiting for all your possible content to load before rendering the page.

    Test your output

    Tools such as the Firebug extension for Firefox and the WebKit Web Inspector help you profile your pages and discover coding errors. You can take a peek inside JavaScript loads created by your widget, view the total resources needed to assemble your widget content, and test your widget performance before releasing new content to the public.

    Summary

    I've outlined just a few of the ways you can optimize your widget code and scale up to more users. Your resources and use cases may vary, but it's a good idea to at least be aware of various optimization options affecting all web content.

    In my next post I'll help you scale widgets using the Google Gadgets platform.

  4. Jul16

    Widget data update formats

    In my last post I wrote about web widget formats: the ways we render widget content within another web site. Web widgets are dynamic, living, breathing pieces of content and often need new data from external services to stay fresh and topical. In this post I'll summarize popular methods of updating a widget's dynamic data using remote HTML framing, plain-text, JSON, XML, and web feeds. I will detail use cases of each format, provide example data to illustrate the data, and document the appropriate request and parsing libraries in major web widget platforms.

    Remote frame

    The simplest widget loads an existing web page as framed content. A widget developer simply needs to set the height and width of his gadget -- a portlet into the remote content in this case -- and specify the remote URL within the widget manifest.

    The remote framing method is not the same as simply adding an iframe or a HTML object within your widget content. Widgets that specify a remote content URL within the manifest file receive extra parameters with each remote request such as user preferences for your widget and the location of JavaScript libraries on the parent platform. These extra assets help developers design web pages inside a fully-controlled environment with the parent platform's look and feel.

    Remote frame content is a good way to add intranet content or other secure sources to a widget user's personalized homepage. All specified URLs are resolved from the user's browser and therefore can directly access content behind the firewall bound to the appropriate Active Directory, LDAP, or other local permission models. A project management application might add a remote framed gadget to allow its customers a quick view inside their upcoming tasks. Cookies and other stored session data passes through with the widget load, meaning your customers will not have to re-authenticate to your site's content.

    Netvibes utilizes the remote framing method to syndicate its UWA widgets to third-party platforms. UWA widgets displayed in a Google Gadgets context request the full widget webpage from Netvibes' servers to render the Netvibes user interface and programmatic logic.

    Example

    Jake 9 months

    A day-care center might offer a view into the playroom for parents to check in on their children from the office. The playroom's streaming video camera is not available to the entire world for security reasons. The daycare center creates an account for each child, allowing a parent or other caregivers to submit payment online, view upcoming events, or check in on the live playroom webcam if they would like. The daycare center might also syndicate the webcam as a remotely framed Google Gadget for quick and easy access to any authenticated user's iGoogle. An interested parent can now glance inside the playroom as part of their personal dashboard.

    Appropriate libraries by platform

    Google
    A content type of url.
    Other
    Construct a HTML object set to type text/html and load the appropriate data URL and standby text.

    Text

    Plain-text is the simplest data interchange format and useful for small or generic tasks. Each widget platform requests the remote resource in an asynchronous manner and returns a string object. You might use a text request to retrieve a small piece of data, HTML markup, or a comma-separated list of values for further processing.

    Example

    A small widget tracks the total outstanding public debt of the United States government. Your widget needs to retrieve the current debt number ($8,878,050,568,679) updated by the Treasury department once every 24 hours. You construct an asynchronous proxied request to a webpage outputting the current number in plain-text format and quickly serve the result inside your widget. The result is cached for 24 hours.

    Appropriate libraries by platform

    Google
    _IG_FetchContent
    Netvibes
    UWA.Data.getText
    Adobe Flex
    HTTPService with a text resultFormat.

    JSON

    The JavaScript Object Notation (JSON) data format is a lightweight way to structure and parse data in JavaScript or Flash. JSON is a subset of ECMAScript 262 edition 3 released in 1999 and corresponds to JavaScript 1.5. JSON is simply a set of JavaScript objects passed over-the-wire and evaluated by a remote system. JSON objects can be parsed much more quickly than the equivalent XML within a scripting environment. JSON can be loaded from the script element, bypassing the same-domain issues of Ajax and local proxies.

    Example

    {'teamname':'Gunners',
    'players':[
    {'name':{'first':'Jane','last':'Doe'}, 'jersey':9, 'position':'striker'},
    ...
    ]}

    The simplified example above defines information about a soccer team expressed in the JSON format. The team has multiple players with unique properties such as a name, jersey number, and position on the field.

    Appropriate libraries by platform

    Windows Live
    Web.Network.Type.Script with a generic proxy.
    Netvibes
    UWA.Data.getJson method. All data is scrubbed, evaluated, and ready for use.
    Adobe Flex
    HTTPService with a text resultFormat. Deserialize the result using corelib JSON decoder.
    Other
    Request the remote JSON using an HTML script element and eval. You might also pass data through a JSON parser if you don't control the source to prevent hostile code inclusions.

    XML

    XML is a general-purpose data format describing structured data. An XML file combines elements, attributes, and text to completely describe a requested resource. Web widget platforms expose a local XML proxy for asynchronous retrieval (Ajax) and caching. Proxied XML results are typically returned as a scriptable DOM object for easy transformations inside developer scripts.

    Many publishers already output XML data for interoperability, backup, or for data portability. A site might output KML files for Google Earth, PowerPoint files in Office Open XML, or the latest tracks played on an Internet radio station. XML data transports provide access to a common set of site data prepared for a variety of possible endpoints.

    Example

    <?xml version="1.0" encoding="UTF-8" ?>
    <todo user="niall" xml:lang="en">
      <task>
        <name>Tie shoelaces</name>
        <priority scale="5">1</priority>
        <duedate>2007-07-15</duedate>
      <task>
      ...
    </todo>
    

    In the example above I describe a hypothetical to-do list expressed as XML. The to-do list belongs to user "niall" and has one displayed task, "Tie shoelaces," that needs to be accomplished by the end of the day. This data might already be exposed by a task management website as a lightweight API and we want to show the user's latest tasks within a personalized homepage environment.

    Appropriate libraries by platform

    Netvibes
    UWA.Data.getXml
    Google
    _IG_FetchXmlContent
    Adboe Flex
    HTTPService with a xml resultFormat.
    Windows Live
    Web.Network.Type.XML with a generic proxy.

    Web feeds

    Web feeds are a specialized form of XML utilizing Atom Syndication Format 1.0 and RSS 2.0.1 vocabularies. Web feeds are popular ways of syndicating content such as blogs, podcasts, or other lists of incremental content changes over time. All web widget platforms include one or more built-in web feed modules for direct transformation of data described in this format. Widget developers can take advantage of existing web feeds output by services across the web to consume and display regularly updated content inside a web widget context. Unlike some built-in feed modules, custom widgets can escape the personalized homepage and integrate with full syndicated widget experiences on social networks, blog sidebars, or any other website.

    Web feeds expand upon a widget platform's support for XML content with specialized data handlers and validators and additional scripting libraries. A web widget platform may already have content from your web feed stored in its database, allowing archive retrieval and pagination beyond the current contents of your feed. Web widget platforms normalize data interfaces across multiple feed types and namespaces, delivering a single match for a single form of expressed content regardless of the data construction method.

    Example

    This weblog outputs a web feed in the Atom Syndication Format. The feed contains the last 10 entries posted to my weblog described with markup elements such as the title of the entry, an entry summary, full content, a link to full entry page on my website, categories, and timestamps specifying the time this entry was originally published and the last significant update.

    Appropriate libraries by platform

    ActionScript 3.0
    Adobe Labs ActionScript 3.0 library
    Google
    _IG_FetchFeedAsJSON
    Netvibes
    UWA.Data.getFeed
    Windows Live
    Web.Network.Type.XML with a rss proxy.

    Summary

    Well-written widgets separate static content, styling, and processing scripts for easy caching and optimal performance. In this post I've outlined the major methods of dynamic content delivery across web widget platforms. Widget publishers hsould choose the data format that best suits their needs based on target platform support, existing data outputs, caching considerations, and user-facing performance. There are no magic bullets for web content delivery and rendering, but now you know your options to develop the best possible widget content.

  5. Jul11

    Basic web widget formats

    Web widgets vary by platform and provider but generally come in four basic flavors: JavaScript, embedded object, blog plugin, and frames. Anyone publishing widget content online should know a few basic concepts shaping their decision and choose the right mix of software and content based on their target. In this post I'll walk through some of the basic advantages, disadvantages, and considerations for each type of widget content and bring you up-to-speed on a few current widget deployment options.

    JavaScript

    JavaScript is a client-side scripting language built-in to web browsers for over a decade. JavaScript interpreters vary by web browser and version, but the language remains a popular choice for dynamically altering the content of a page and its interactions.

    JavaScript executes as part of the web page with access to the current page structure and markup (commonly referenced as the DOM). Your JavaScript widget may add other elements to the page such as additional scripts, styles, or embedable objects.

    Widgets powered by JavaScript can customize their content based on other page content. Your widget might scan a blog post looking for tags and categories to deliver relevant advertising or Flickr photos. Your JavaScript widget might alter the style of the page with special skins and themes.

    Each web widget platform offers its own JavaScript abstraction libraries to help widget developers serve cached content and offer a consistent user experience across multiple browsers and widgets. A Google Gadget developer might utilize Google's tabbed user interface or access a user's stored preferences. A Windows Live developer might take advantage of Microsoft's ASP.net Ajax libraries for anything from string concatenation to element creation. Each platform offers its own unique integration and scalability helpers.

    Embedded plugin objects

    Web browser functionality is typically extended through browser plugins. Plugins are small desktop applications integrated with a web browser environment to provide additional on-page functionality. Adobe Flash, Microsoft Silverlight, and Apple QuickTime are three of the most popular browser plugin environments for widget creation. Each of these plugins create special forms of playback and interaction within a packaged application environment.

    Browser plugin content executes these miniature external applications within a browser window, creating a small portlet into rendered content. Plugins extend a browser's functionality by design, avoiding feature creep and licensing issues of a stand-alone browser. The ubiquity of popular plugins distributed through new PC sales, packaged with other applications, or installed on-demand help create a base ecosystem for development and code distribution. The capabilities of each plugin vary by version but, like modern browsers, most plugins ship with an automatic update mechanism.

    Widgets powered by plugins function within a certain portion of the page defined by the embed or object elements. New content does not inherit the CSS styling on the page and therefore may stand-out in a blog sidebar or social network profile. Standing out could be a good, bad, or neutral thing depending on your content and the page owner's design tastes.

    Each target widget platform has a preferred method of handling plugin objects and occasionally restricted plugin access. I'll outline a few popular platforms below.

    MySpace widgets use Flash version 9 and above, requiring ActionScript 3, version 2 of the Adobe virtual machine interpreter, and converts HTML into its preferred object format before saving content to a user's profile.

    Google Gadgets utilizing Flash embeds function best when paired with the Google Gadgets JavaScript flash library. This JavaScript call checks the client's Flash Player version against your version requirements before attempting to load any content. The library also constructs the appropriate HTML object for the client browser.

    Facebook prefers Silverlight content embedded on the page using FBML.

    Blog plugins

    Popular blogging software such as Movable Type and WordPress let authors install and configure specialized widgets designed for the platform and extended through plugins. Blog plugins are rendered as an integrated part of each blog page and exist as first-class citizens within a larger content structure.

    A blog plugin might gather data on a regular basis on behalf of the blog author, storing a reference to his latest photographs stored on Slide or his latest bookmarks stored on del.icio.us in a local SQL database for quick and structured access. A blog author would configure the on-page display of gathered data through the blogging software's built-in widget administration interface.

    Blog plugins are executed on the server and delivered to a blog viewer's browser as a single HTML file. Poorly written blog plugins could slow down or otherwise incapacitate an author's blog so it's especially important to follow best practices of integration and execution within this environment. Blog plugins are written for a specific version of a specific piece of blogging software. Database API and other software tie-ins change over time so you will need to choose a minimum version to support for best feature and addressable market trade-off.

    Framed content

    Web widget content typically executes as a webpage within a webpage for security and containment purposes. The main web page loads all available widget content and creates appropriate inline sub-pages for each. These sub-pages are expressed within the page markup as inline frames (iframe) or a HTML object. Framed content isolates each web widget with limited privileges to protect page visitors from poorly written or malicious code.

    Widgets within framed content do not have direct access to the full contents of the parent page or its user data. Web widget platforms serve as a bridge between the content and preferences of a main page and the framed widget content. A widget displaying photographs from your family vacation or the latest sports scores do not necessitate elevated privilege levels and perform well within a framed page environment. Widgets that request more permissions than needed could raise more author-facing warning messages within each widget platform. Widget developers should consider their on-page data requirements when creating and deploying a web widget.

    Most web widget platforms allow developers to turn framed content on or off within a widget's manifest file. Google Gadgets escape the frame if defined as type "html-inline." Netvibes references a meta element named inline for a similar function. You should be able to adjust your widget's permissions requirements before publishing to the outside world.

    Some widget platforms offer widget certification and partner programs. Certified widgets might load from the same domain as the target platform -- reducing warning messages and providing better run-time access -- and usually carry a badge of honor and special promotion within a platform's widget gallery.

    Mix and mash

    The four widget methods listed above do not exist in isolation. Your Flash widget might be wrapped in a JavaScript widget. Your WordPress plugin might generate framed content. It really depends on what works best for your content and your targeted users.

Niall Kennedy Niall Kennedy is a web technologist in San Francisco, California in the United States. I am very interested in the world of... MORE »

Search this weblog:

Subscribe:

Latest feature: Widget development

Archives: Popular Categories

Sites: More from Niall