Latest News!

News

Smashing Magazine Feed

For Professional Web Designers and Developers
  • Case Study: Typographic Design Patterns And Current Practices (2013 Edition)

      

    Good typography has always been a defining aspect of effective Web design, and this holds true especially for websites in which the emphasis is on presenting a large amount of content — specifically, articles, news and stories. Whether for a magazine or international newspaper, the designer of any website that distributes a lot of content has always had to consider typographic details as seriously and thoroughly as a print designer would.

    In 2009, we conducted a survey of then current typographic practices. Since then, responsive design techniques have clearly gained momentum and established their place in the landscape of CSS layout. With the advent of mobile, new modes of browsing websites and reading text have emerged.

    Online publications have had to reevaluate how their content is presented on mobile devices. Web typography is as rich, versatile and accessible as ever before. Yet new opportunities introduce new complexity; and with new implementation challenges, we are all spurred to reconsider our practices.

    Now, three years later, we’ve reviewed the original study and explored how Web typography has changed over these years. We spent countless hours between February and April of this year collecting new data and exploring common developments and trends in Web typography.

    How Did We Conduct The Study?

    We have compiled relevant data from over 50 well-respected websites to address these questions. For this study, we selected a wide variety of international newspapers, magazines and blogs, all of whose typographic choices should have been carefully and thoroughly weighed. We chose publications and organizations that have a very large readership (such as The Boston Globe and The Financial Times) as well as specialized magazines with smaller yet often more demanding readerships (such as A List Apart and UX Booth).

    These websites focus primarily on text-based content rather than on generic environments such as Instapaper and Readability. As such, they need to be highly legible in order to ensure that users continue visiting and reading on their websites. Because readability of content is (or rather should be) the main design goal of these publications, the techniques they follow could be considered good practices. However, the results presented in this study should be taken with a grain of salt.

    Issues We Were Interested In

    The questions asked in our first study nearly four year ago remain relevant but need to be complemented by questions about the challenges of mobile devices. How widely has responsive design been adopted by publications, if at all? Has there been any change in the typographic choices of big and small publications? How many weights of a large font family should we deliver to mobile devices? How large should the font size of body copy be? How should the font size change on a responsive website? Optimizing readability could require changing the font’s style, size and spacing according to the viewport’s width and height.

    The second article in this series will address the growing diversity of eBook readers and mobile apps whose purpose is to give users a pleasant, improved or enhanced reading experience — from desktop readers down to smartphone readers. We were curious about the specifics of design and typographic choices that make reading articles in these applications more pleasing than reading on the original websites.

    Note: For the sake of continuity, we have stayed close to the format of the original study from 2009. This article is meant to update the data, and hopefully detect new trends and reach new conclusions.

    Typography In Online Publications

    After carefully analyzing the style sheets in the publications in this study, we compiled a comprehensive spreadsheet of typographic points and collected the relevant data. You can view a spreadsheet of the raw data, which contains more data than was pertinent to this article.

    Not limiting ourselves to the questions in the original study, we will broach issues that have arisen since then as a result of responsive design techniques, and we’ll examine whether such techniques are being applied at all. This led us to the following questions:

    1. How popular are serif and sans-serif typefaces in body copy and headlines?
    2. Which fonts are used most frequently?
    3. What is the average font size (on narrow, mid-sized and large screens)?
    4. What is the average ratio of the font sizes of headlines to the font sizes of body copy?
    5. What is the average line height of body copy?
    6. What is the average ratio of line height to font size in body copy?
    7. What is the average ratio of line height to line length in body copy?
    8. What is the average amount of space between paragraphs?
    9. What is the average ratio of paragraph spacing to line height in body copy?
    10. How are links styled?
    11. How many characters per line are common in body copy?
    12. How often are links underlined?
    13. How often are font fallbacks used?
    14. How often are responsive design techniques implemented?
    15. Which ratios of display sizes are discernible?
    16. How do websites deal with the performance of Web fonts?

    To answer these questions, we collected more than 40 data points, all of which can be found in the aforementioned spreadsheet. We can extract several rules of thumb from this data. We wouldn’t recommend acting on the data from this study blindly; the statistical data, however, will no doubt yield useful insights.

    Popular Serif And Sans-Serif Fonts

    “Which typeface to use?” Obviously, this is one of the most important questions a designer has to answer when considering Web typography. The typeface will set the tone for the entire website, and a poor choice could send the wrong message or thwart the intended atmosphere. The argument for either serif or sans-serif hasn’t been won yet. Interestingly, looking back to the results of the 2009 study, sans-serif typefaces seemed to be more popular in body copy and headlines. The last four years have seen a tiny shift away from that.


    Serif and sans-serif are almost equally popular in headlines.

    The motivations of designers likely haven’t changed much. Serif fonts apparently stand out in headlines, but arguments have been made for serifs’ ability to guide the reader and for its readable structure in body copy as well. Still, contrasting a serif body with a sans-serif headline or vice versa can improve the overall visual appeal and readability of a website.

    The data suggests that serifs have gained in popularity in recent years, leading almost to a reversal in common usage in the last four years, at least where body copy is concerned.


    Serifs have strongly gained in popularity in body copy.

    • Half of the websites analyzed use serifs in their headlines, the other half sans-serifs. The two most popular typefaces are Georgia — used on such websites as The Guardian and the Financial Times — and Arial — found on Zeit.de and the BBC’s website.
    • Only 37% use a sans-serif typeface for body copy.
    • The most popular serif typefaces for headlines are Georgia (14%) and Chaparral Pro (6%).
    • The most popular serif typefaces for body copy are Georgia (20%) and Chaparral Pro (4%).
    • The most popular sans-serif typefaces for headlines are Arial (10%) and Freight Sans Pro (4%).
    • The most popular sans-serif typefaces for body copy are Arial (14%) and Helvetica (6%).
    • However, 66% of headline typefaces and 39% of body copy typefaces are found in only one instance.

    So, in summary we can state that nearly two thirds of the websites analyzed use serifs for body copy, and Georgia and Arial are still the most common primary typefaces. However, our most surprising find is that a majority of websites use non-standard fonts as their primary typeface — 39% of body copy and 66% of headlines. This development is truly interesting, because it shows that typography has become an important element in establishing brand identity and character. These numbers indicate growing typographic diversity on the Web — which we should probably expect anyway.


    A majority of websites use non-standard fonts as their primary typeface.

    The growth of “bulletproof” font-delivery services such as Typekit and Fontdeck likely explains the increasing variety of primary typefaces. Fallback typefaces are predominantly standard core Web fonts. Times, Times New Roman, Georgia, Helvetica and Arial are most often used in CSS font stacks. Mobile platform fonts such as Droid Sans, Palatino and Cambria are almost never used.

    Ironically, a consequence of the resurgence in serif typefaces is that Times and Times New Roman, which had almost been written off as too old-fashioned in the last study, have made kind of a comeback as the two most popular fallbacks. Roughly 11% of headline and body copy fallbacks have Times, and another 11% have Times New Roman.

    There is much literature on typography in Web design, most of which discusses the applications of serif or sans-serif typefaces. Increasingly, the argument for better readability combined with artistic value supports a judicious use of both styles. Douglas Bonneville discusses the benefits and best practices of combining serifs and sans-serifs, and Simon Pascal Klein discusses the intricacies of font families and makes further typographic considerations in his article “Achieving Good Legibility and Readability on the Web.”


    The Great Discontent combines both the Stratum and Meta Serif Web Pro fonts to generate a dynamic yet respectable feel.

    Compared to the previous study’s results, Verdana and Lucida Grande are the big losers. Verdana is used only twice as a primary font, and neither is used more than once as a fallback font. Chaparral Pro and Helvetica have risen in prominence. The increasing diversity and individuality in design is due to both the increased use of font foundries and the wider range of Web fonts.

    One discovery of the previous study, that “alternative” fonts are more common among headline typefaces, is still proving accurate. No doubt, the general belief that experimentation is best applied to small details still stands. The look and feel of a page can be adjusted just enough by changes to the font family of headings, rather than by drastic changes to body copy. However, the overall use of alternative fonts for body copy has increased dramatically, creating a much richer and more diverse typographic landscape on the Web.

    Light Or Dark Background?

    The previous study concluded that a large majority of websites favored dark on light color schemes. Not much has changed, although the websites surveyed this time are more varied in their light background tones.


    An Event Apart demonstrates the readability of a subdued color scheme.

    Several websites have a less aggressive contrast of an off-white or even beige background with dark-gray text. The off-white is often chosen to lower contrast. The designers in this case have clearly opted for a comfortable, lengthy reading experience.

    Black text on a white background is a common pattern for body copy. The contrast is easy on the eyes and is, at least among these websites, the status quo.

    Average Font Size For Headlines

    Generally, the font size of headlines is chosen according to the typeface of the body copy. Still, it’s interesting to see what common ranges designers prefer for body copy and headlines. In this study, the headlines for large display sizes average at roughly 38 pixels. Of course, we made sure that the text always displayed at the actual size, without any zoom.


    The most popular sizes range from 20 to 32 pixels.

    You can easily notice the increase in font size since the last study. Not only did the average increase by more than 10 pixels (!), but the range of headline sizes starts further up, at 20 pixels, and tops out at an impressive 212 pixels in the case of The Great Discontent. This publication is an exception, with its magazine-like headlines and smaller font sizes for headings.


    We’re going further up. The Great Discontent shows an impressive 212 pixels font size.

    Average Font Size For Body Copy

    With readability as the determining criterion, the average pixel size of body copy has increased in four years as well. Back then, most of the websites were between 12 and 14 pixels in font size. Now, 14 pixels is as popular as 16 pixels; each is used on 13 websites.


    14 pixels is also The Verge’s font size. While some websites offset the first paragraph of an article with a larger font size, many, like The Verge, follow a uniform size.

    Ratio Of Headline to Body Font Size

    We’ve updated our rule of thumb based on the current average ratio between headline and body font size. Don’t follow this rule blindly; rather, just keep it in mind as you make decisions in your projects.

    Headline ÷ Body Copy = 2.5

    According to our study, on average, the ratio between the headline and the body copy is around 2.5. The traditional scale (6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 21, 24, 36, 48, 60, 72) and the Fibonacci sequence (16, 24, 40, 64, 104) are still relevant, of course, and represent a more naturalistic approach. The golden ratio (1.618) might also yield an organic effect, too.

    Optimal Line Height For Body Copy

    Leading (or line-height in CSS) will always depend on your font size and measure (or line length). But in general, the longer the measure, the longer the leading should be. Therefore, presenting a chart of the most popular leading values in pixel units wouldn’t make sense here. More appropriate for you would be to use a relative unit, such as an em or percentage value, that determines the ratio between leading and measure and between leading and font size.

    This latest study reveals the following:

    • line height (pixels) ÷ body copy font size (pixels) = 1.46
      Classic typography books recommend 1.5, a value backed up by this and our last study. Very few websites use anything less than that. The number of websites that go above 1.48 decreases as you get further from this value.
    • line length (pixels) ÷ line height (pixels) = 24.9
      The average line length (570 pixels, excluding margins and padding) has grown comparatively less than font size and line height have since 2009 (the latter averaging 22.9 pixels). The average line lengthened by approximatively 5% (from 538,64 pixels in 2009), while the average line height has increased from 12 pixels in 2009 to 13 pixels in 2013.
    • space between paragraphs (pixels) ÷ line height (pixels) = 1.39
      In the first study, it turned out that paragraph spacing (i.e. the space between the last line of one paragraph and the first line of the next) rarely equaled the leading (which would be the main characteristic of a perfect vertical rhythm). According to our results, paragraph spacing is around 1.39 × the paragraph leading. Paragraphs are more clearly delineated with this increased ratio, thus increasing readability.

    Multiplying the value of your body’s font size by 1.46 would give you the optimal line height, which you could then adapt to your font style. Multiplying this new value by 24.9 should give you the optimal line length. Note that the layout would also need gutters, margins and padding to let the body copy breathe.

    Characters Per Line

    As explained by Robert Bringhurst, the classic rules of Web typography dictate that the optimal number of characters per line is 55 to 75. Our data shows that at their actual size (i.e. with no zoom and at the default font size), most websites average 83.9 characters per line at a widescreen resolution (in our case, a browser width of 1100 pixels).

    While this average fluctuates quite significantly when the browser is at various other widths — between 83 and 86 characters per line at display widths of 700, 950 and 1600 pixels — only in smaller views of 500 pixels this average comes close to the classic rule. At that width, the average lies around 77 characters per line.

    This is most likely the result of an attempt among designers to balance the font size with the amount of text displayed on narrow screens. With more characters displayed per line, the font size would have to become small, making the reading experience a bit more difficult on the eyes.

    The highest number is, of course, much higher, but in general most designers stay in the range of 75 to 90 characters. In the most extreme cases, SB Nation has 55 characters per line, and Polygon averages 118 for the introductory paragraph. A more exact average could be derived by averaging several lines. But such an in-depth analysis probably would not vary greatly from the average that we calculated here. Still, the discrepancy between the number of characters at different widths is peculiar.


    Polygon displays more characters per line in the introductory paragraph than in the rest of the article. However, the font size of that paragraph is larger as well.

    Web Typography And Responsive Design

    A burning issue we wanted to explore was the impact of of responsive design in Web typography today. The results were surprising: 22 out of 52 (i.e. 42%) of the websites we analyzed show (minor or major) changes when the browser size changes. Considering that responsive design has been around for two years, that number is quite impressive. We calculated the number of characters per line, the body font size and the headline font size at five browser widths (and experimented with the height as well): 500, 700, 950, 1100 and 1600 pixels. The font sizes for those three metrics do not differ greatly across the screen sizes — except at the 500-pixel view.

    Unexpected, though, were the visual changes that occurred as we resized the browser. Changes in layout, image scaling, content and font size were evident to varying degrees on 22 websites. The changes are as minimal as images being scaled down to suit the display width. In some cases, however, the websites display other minor and expected changes. At the 500-pixel view, for example, the menu is often replaced by an icon; design components are moved from a multi-column layout to a single column; and both images and fonts are scaled.

    No sign of responsive design was evident on 30 websites, including major publications such as The Financial Times and The Economist. At least some, if not all, of these websites seem to opt for a separate mobile website or application. The Financial Times immediately invites mobile visitors to use its FT app. At the moment, large online publications seem to prefer to invest in an app than in responsive design. If this trend continues, then the question becomes, how much will users be annoyed by being prompted to download an app for every single publication they’re interested in.

    Despite this, we were happy to find that the layouts of the large majority of websites do not break when being zoomed in.

    Some Numbers on the Implementation of Responsive Design

    42% of websites implement responsive design changes, including for layout, image scale, content and font size.

    At a display width of 500 pixels:

    • Average line height: 28 pixels
    • Average font size of body: 15 pixels
    • Average number of characters per line: 77

    At a display width of 700 pixels:

    • Average font size of headlines: 36 pixels
    • Average font size of body: 15.6 pixels
    • Average number of characters per line: 82.7

    At a display width of 950 pixels:

    • Average font size of headlines: 37.9 pixels
    • Average font size of body: 16.1 pixels
    • Average number of characters per line: 84.8

    At a display width of 1600 pixels:

    • Average font size of headlines: 40.7 pixels
    • Average font size of body: 16.2 pixels
    • Average number of characters per line: 86.8

    These averages might be somewhat skewed because of the mixture of responsive and non-responsive websites. But they show how little the body font size and characters per line change over varying widths. The only exception is the 500-pixel width, which have a lower number of characters per line.

    Performance Considerations

    While embedded fonts are slowly becoming a de facto standard in Web design, they also introduce overhead in performance because, well, they have to be loaded. Chris Coyier recently discussed the idea of loading Web fonts only on large screens to avoid the performance hit. You could also load Web fonts into AppCache or LocalStorage first and show them on subsequent page loads.

    Moreover, you could use Google’s WebFont Loader to ensure that the content is displayed in fallback fonts even before the Web fonts have loaded, and then switch to the Web fonts once they have completely loaded (this is what we’re implementing in this very moment).

    Our study shows that Web fonts are indeed a heavy bottleneck in performance, with 5.7 font files being loaded on average, totalling an average of 133.5 KB of extra bandwidth. In cases such as a page being loaded on a slow mobile connection, the user would initially see no text other than the underlining of links (apparently due to the use of the border-bottom property). Only once the fonts have loaded would the text be visible — and even then, elements would appear one by one (headings, then subheadings, then body copy). We can avoid this suboptimal experience by properly adjusting the CSS font stack, as Richard Rutter explains in his talk “Responsive Web Fonts” (slidedeck).

    Other Findings

    • 45% of websites underline the links in body copy. The others do so only on hover or not at all.
    • 71% of websites highlight links with color. The rest do not or only on hover.
    • 99% of websites left-align text.
    • No website uses hyphenation.
    • 84% of websites use the same fonts in the print and standard style sheets.
    • The loading weight of home pages averages around 1.346 MB. Article pages are marginally less, at around 1.146 MB.
    • The websites average 119 HTTP requests!

    Conclusion

    This study has revealed a set of common practices in Web typography. These results should not be interpreted as law. They should not be interpreted as “best” practices; rather, just as rough guidelines that we encountered in current Web design.

    For example, the performance hit introduced by Web fonts and the (huge) number of HTTP requests should be reduced as far as it’s possible, while the content-out approach in responsive design would dictate how the font size would need to adjust depending on the settings in which it’s used. These findings are no doubt just a snapshot of current trends and may very well be outdated in a year’s time.

    • Serif fonts are more popular than sans-serifs for both headlines and body copy. There is, however, a trend to mix sans-serifs and serifs to contrasting effect.
    • The most common fonts for headlines are Georgia, Arial and Chaparral Pro. But the majority of websites are individualized and use less common fonts.
    • The most common fonts for body copy are Georgia, Arial and Helvetica. But, again, the majority of websites are individualized and use less common fonts.
    • The most popular font size for headlines is between 29 and 32 pixels.
    • The most popular font size for body copy is between 14 and 16 pixels.
    • headline font size ÷ body copy font size = 2.4
    • line height (pixels) ÷ body copy font size (pixels) = 1.47
    • line length (pixels) ÷ line height (pixels) = 24.8
    • space between paragraphs (pixels) ÷ line height (pixels) = 1.43
    • The optimal number of characters per line is between 55 and 75, but 75 to 90 is more popular.
    • Body text is left-aligned. Hyphenation is not used at line endings. And links are underlined and/or highlighted with bold or color, sometimes only on hover.
    • Mobile devices are mostly adapted to via responsive design, although some publications opt for a dedicated app.

    The decision of whether to modify any typographic element always lies with the designer. Most of the results shown in these websites are likely the outcome of much trial and error. When designing a new website, you might want to stay close to these parameters, but with adjustments to suit your layout. Feel free to review the study’s spreadsheet for the raw data.

    As we mentioned at the beginning, the second article in this series will deal with the intricacies of eBook readers and mobile apps. We don’t necessarily expect very different results. However, apps do offer more interactivity to the user. It will be interesting to see how much developers take advantage of the range of possibilities in mobile apps. Because there is not yet an inordinate number of readers on the market, we’ll accumulate data on as many readers as possible.

    More Studies On Smashing Magazine?

    Interested in more studies? Let us know what you’re interested in, and we’ll see what we can do!

    What kind of studies would you like to see on Smashing Magazine?

    (al)


    © Jan Constantin for Smashing Magazine, 2013.



  • A Beginner's Guide: Migrating A Website To WordPress Is Easier Than You Think

      

    Now powering over 17% of the Web, WordPress is increasingly becoming the content management system (CMS) of choice for the average user. But what about websites built with an outdated CMS or without a CMS at all? Does moving to WordPress mean starting over and losing all the time, energy and money put into the current website? Nope!

    Migrating a website (including the design) over to WordPress is actually easier than you might think. In this guide, we’ll outline the migration process and work through the steps with a sample project. We’ll also cover some of the challenges you might encounter and review the solutions.

    About This Guide

    Before we get to work, let’s establish some context. First, this guide was written primarily with beginners in mind and will be most helpful for basic websites. Some of you will likely encounter advanced aspects of WordPress migration, but they are beyond the scope of this guide. If you’re tackling an advanced migration and get stuck, feel free to share your difficulty in the comments below.

    Objectives

    The objective of this guide is to help you with the following:

    • Plan an effective migration to WordPress.
    • Walk through the technical steps involved in migrating.
    • Get ideas and resources to solve common migration challenges.

    Assumptions

    I assume you have basic familiarity with WordPress. Previous development experience with WordPress would be helpful, but not necessary. I also assume you have an existing website and design that you want to migrate to WordPress.

    Starting With A Plan

    Basic Steps

    Here are the basic steps that I recommend you follow for a typical WordPress migration:

    1. Evaluate website.
      Work carefully through the pages on your existing website, identifying all of the types of content (standard pages, photo galleries, resource pages, etc.) and noting any areas that need special attention.
    2. Set up environment.
      Set up WordPress and get ready to import.
    3. Import content.
      Bring over and organize your content, whether via an importing tool, manual entry (for a small amount, when no tool is available) or a custom importing process.
    4. Migrate design.
      Incorporate your existing design into a custom WordPress theme.
    5. Review website, go live.
      Carefully review the import, making adjustments where needed, set up any URL redirects, and then go live.

    With this outline in mind, let’s work through each step in detail.

    Start With A Plan

    The key to a successful migration is to carefully evaluate your current website. You need to figure out how to import and structure the content in WordPress before carrying over the design.

    While the principles are the same across migration projects, the details often vary. So, below are two lists of questions to ask as you work out a plan.

    Imported Content

    • How much content needs to be imported (number of pages, number of images, etc.)?
    • Is the volume low enough to be imported manually, or do you need a tool?
    • If you need a tool, does one already exist?
    • Can the content be categorized into the standard “posts” and “pages,” or does it call for custom post types?
    • Does extra content need to be stored for certain pages (custom fields, taxonomies, etc.)?
    • Will the URL structure change? If so, will the old URLs need to be redirected?

    Existing Functionality

    • Does the website integrate any third-party services (data collection, reservations, etc.)?
    • Do any forms need to be migrated (contact forms, application forms, etc.)?
    • Is access to any content restricted (such as members-only content)?
    • Does the website sell products (digital or physical)?
    • Do any administrative tools need to be carried over (such as custom CMS functionality)?

    A Working Example

    My brother, Joshua Wold, has volunteered a website to serve as an example; it’s for a side project of his in which he sells posters and postcards of a Vegan Food Pyramid. He built the website in plain HTML, with some basic PHP includes for the header and footer. Below is a screencast of me evaluating the website to give you a sense of how the process will work. Enjoy!

    Set Up WordPress

    Before importing the content, we need to get WordPress ready to go. If you’re just experimenting or if you prefer offline development, start with a local installation of WordPress. Otherwise, the next step is to install WordPress with your current hosting provider; or you could use the migration process as a great opportunity to move to a new host.

    Once WordPress is up and running, you’re ready for action!

    Setting Up WordPress

    For our example, we’ve installed WordPress with the same host, setting it up in a /wp directory for the duration of the migration process.

    Settings and Plugins

    With WordPress installed, we’ll make a few minor adjustments:

    • Update permalinks.
      Go to Settings → Permalinks to make changes. In most cases, I’ll switch to “postname”-style permalinks.
    • Update users.
      I create an admin-level account for myself and any admin or editor accounts that are needed for clients and collaborators. I also remove the default “admin” user name if it exists (a basic but wise step for WordPress security).

    Depending on the needs of the project, we might have to preinstall plugins. Here are the major categories of plugins:

    • Form management
      Migrating a form “as is” is usually a mess; simply recreating it using a forms plugin is usually easier. My current favorite is Gravity Forms ($39+ per license). Other options are Formidable (with free and pro versions) and Contact Form 7 (entirely free).
    • SEO management
      Search engine optimization (SEO) is a touchy subject. My philosophy is to build content for people, not for search engines. That being said, there is a common-sense approach to SEO that is solidly supported by the WordPress plugin ecosystem. And if your old website includes custom meta descriptions, giving them a new home during the importing process is important. I recommend WordPress SEO (free).
    • Multiple languages
      If your old website supports multiple languages, WordPress has you covered. My plugin of choice is WPML ($79 per license, free for non-profits). Another option is qTranslate (free).
    • Security
      WordPress security is a topic near and dear to me. The increasing popularity of WordPress has made it a target for security attacks. WordPress itself is rarely the problem; a poorly secured hosting environment or an outdated or poorly developed plugin usually is. I use managed WordPress hosting for the majority of my projects, which offers a good foundation for solid WordPress security. Options include WPEngine, ZippyKid, Pagely and Synthesis. In addition to managed hosting (and especially if you opt for a non-managed host), consider installing a security plugin, such as Better WP Security (free) or Wordfence (also free). Last but not least, review the “Hardening WordPress” guide in the Codex.
    • Backups
      If you opt for managed hosting, backups are usually included (make sure, though). If you’re managing backups yourself or you want an extra layer of data protection, great options are available, including VaultPress ($15+ a month), CodeGuard ($5+ a month), BackupBuddy ($75+ per license) and BackWPup (free).

    Import Content

    With WordPress up and running, it’s time to bring over all of your content.

    If your old website has a CMS, an importing tool might be available. Start by viewing the list of content-importing scripts in the Codex. If there’s a match, great! Follow the instructions and get to work. If all goes well, you’ll have migrated the content over without any trouble.

    If your old CMS is not in the list or you don’t have a CMS at all and you’ve got fewer than 100 pages, then manual migration is probably the way to go. Copy and paste the contents, noting the old URLs as you go (tracking the migration in a spreadsheet is a good idea).

    4

    If you’ve got a custom CMS or a database of records without an importing tool and a high volume of content, then you might want to bring in a specialist to move the content over before continuing. The higher the volume of content, the higher the chance of human error and the more important automating it becomes.

    For our project, I’ve migrated the content manually and replaced the existing navigation with a WordPress menu. You can watch the process in this next screencast:

    Bring Over The Design

    With our content in WordPress, it’s time to bring over the design. Incidentally, if you’re considering a new design, then now is a great time to look at the many excellent WordPress themes out there, both in the official repository and in third-party marketplaces such as ThemeForest and Creative Market. For our purpose, I’ll assume that you’re happy with your design.

    Evaluating A Design

    Evaluate the source code of a prospective design as best you can before tackling the migration. If the code is table-based or more complex than you’re comfortable with, then migrating the design might not be worth the effort. While anything is possible (I’ve migrated some complex table-based designs in my time), not everything is practical.

    Working With Source Code

    In my experience, the easiest way to migrate is to work directly with the source code in the browser. While having access to the original hosting environment can be helpful (especially when working with a lot of images and downloadable files), the ways that websites are built vary so widely that you’ll often have to reverse-engineer the original architecture in order to derive anything useful.

    5

    Going directly to the source code in your browser of choice will save a lot of time and, barring any important “behind the scenes” functionality, give you everything you need. Google Chrome is currently my browser of choice, and I’ve pulled our source-code samples directly from the browser. (In Chrome, go to Menu → Tools → View Source, or just right-click to bring up the contextual menu.)

    Create A Custom Theme

    If you’re new to them, learn about using themes in the Codex. For the migration process, you can either build a new WordPress theme from the ground up or modify an existing theme to meet your needs. I recommend the latter.

    Most of my migration projects have started with the latest version of WordPress’ default theme (currently Twenty Twelve). Recently, I stripped down the default theme to create my own migration starter theme, which I’ll use in our example and which you’re welcome to use yourself. (Feel free to suggest improvements!) Let’s get to work.

    Download a copy (ZIP) of the migration starter theme or follow along in your own theme of choice as we work through the relevant theme files.

    1. Style Sheet

    Our first step is to bring over the styles from the old website. In most cases, this is as simple as searching the source code for references to .css and then copying and pasting the contents from those style sheet(s) into our own style.css. Let’s get to it.

    1. Open up style.css.
    2. Replace the details of the theme (“Name,” “URI,” “Description,” etc.) with your own.
    3. Paste in the styles from the old website.

    A Note About Images

    As you migrate the style sheet(s), search for and update any references to images. In general, I like to keep all images in an /images/ folder within the theme’s directory. More often than not, changing the locations of images referenced in the original CSS is necessary, and I make sure to update all references in the style sheet and templates accordingly.

    2. Header

    The next step is to create the header for our new theme. Our objective here is to merge the structure of the current code base with WordPress’ templates. Here’s what we’re going to do:

    • Replicate the HTML structure of the old website.
    • Replace the static menu with a WordPress-powered menu.
    • Use WordPress’ title tag and leave the wp_head hook in place.
    • Merge any other relevant tags from the old header.

    Let’s get into the code!

    Original HTML

    
    <!DOCTYPE HTML>
    <html>
    <head>
    <title>Vegan Food Pyramid posters, postcards and wallpapers</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="google-site-verification" content="PO3bWDpUEh4O6XXwnmfyfxrKRDf8JsRrNIcGdzv3POs" />
    <link rel="stylesheet" type="text/css" href="/style.css" media="screen" />
    <link rel="shortcut icon" href="http://www.veganfoodpyramid.com/favicon.ico?v=2" />
    <script type="text/javascript" src="//use.typekit.net/tty6xpj.js"></script>
    <script type="text/javascript">try{Typekit.load();}catch(e){}</script>
    
    </head>
    <body>
    <a href="http://veganfoodpyramid.com"><h1 id="logo">Vegan Food Pyramid</h1></a>
    <ul class="menu">
       <li><a class="active" href="http://veganfoodpyramid.com">Products</a></li>
       <li><a href="http://veganfoodpyramid.com/wallpaper.php">Wallpaper</a></li>
       <li><a href="http://veganfoodpyramid.com/about.php">About</a></li> 
       <li><a href="http://veganfoodpyramid.com/contact.php">Contact</a></li>
    </ul>
    

    Merged Header (header.php)

    
    <!DOCTYPE html>
    <html>
    <head>
       <title><?php wp_title( '|', true, 'right' ); ?></title>
       <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
       <meta name="google-site-verification" content="PO3bWDpUEh4O6XXwnmfyfxrKRDf8JsRrNIcGdzv3POs" />
       <link rel="shortcut icon" href="http://www.veganfoodpyramid.com/favicon.ico?v=2" />
       <script type="text/javascript" src="//use.typekit.net/tty6xpj.js"></script>
       <script type="text/javascript">try{Typekit.load();}catch(e){}</script>
       <?php wp_head(); ?>
    </head>
    
    <body <?php body_class(); ?>>
    
       <header>
          <a href="http://veganfoodpyramid.com"><h1 id="logo">Vegan Food Pyramid</h1></a>
          <?php wp_nav_menu( array( 
                'theme_location' => 'primary',
                'container' => false,
                'menu_class' => 'menu'
          ) ); ?>
       </header>
    

    Explanation

    One of the challenges of migration is deciding whether to improve code as you go along. Our project has a few areas that could be improved, but Joshua and I agreed to leave them as is. Most of you will be tackling the migration of a design that hasn’t been coded to current best practices (although, in fairness to the original coder, they may have been best practices at the time).

    Website Review

    If time and opportunity allow, I encourage you to improve on the code. Otherwise, take comfort in the fact that, with the website now on WordPress, improvements will be a whole lot easier down the road.

    Let’s work through the changes we’ve made!

    • Doctype
      Make sure to carry over the same doctype. In this case, the original HTML already has an HTML5 doctype (a relatively rare occurrence on old websites). Using a modern doctype in a code base written for an older specification (such as XHTML or HTML4) could break the layout (especially in old browsers).
    • Meta tags
      I usually bring over the majority of meta tags as is, replacing them in WordPress. The exception in our case is the reference to the style sheet, which is being inserted automatically via wp_enqueue_style in the functions.php file.
    • Scripts
      Scripts can be tricky. If a script belongs on every page (such as a tracking script or font script), then putting it directly in the header (or footer) file is fine. If it needs to appear only on certain pages, then a conditional tag will do the trick. As a best practice, register all scripts and add them to the header (or footer) via wp_enqueue_script. If you’re up for the challenge, I recommend doing it this way. (Check out a tutorial on enqueuing TypeKit the right way.)
    • wp_head
      Leave <?php wp_head(); ?> at the bottom of the </head> tag in the merged header file. WordPress uses wp_head, among other things, to enqueue scripts and style sheets that are referenced in the theme (usually in functions.php) and in plugins that you’ve installed. Without wp_head in place, most front-end plugins won’t work.
    • body_class
      Notice our use of the <?php body_class(); ?> tag. WordPress uses this to provide a series of helpful classes to the <body> tag depending on the page being viewed. In our example, the <body> classes weren’t being used. Yours might have unique IDs or classes on each page, in which case you can create a custom function using conditional tags to add the appropriate classes to the corresponding pages. Have a look at the Codex for some examples.
    • WordPress menus
      Switching to a WordPress-powered menu is one of the more complex tasks in most basic migrations. It will be fairly straightforward for us. We have a menu with simple markup that uses an active class (generated via PHP) to indicate which page the visitor is viewing. The wp_nav_menu function is highly flexible and offers built-in functionality to handle the current state of an element in the menu. I’ve updated the references in the style sheet to the active class and changed them to use the equivalent generated by wp_nav_menu, which is current-menu-item. Watch the screencast on importing content to see how I’ve set up the menu for our example.

    And that’s a wrap! Let’s move on to the next piece.

    3. Footer

    The footer is usually the most uneventful template in the migration process. As with the header, our objective is to merge the relevant parts of the original source code. Let’s get to it!

    Original HTML

    
    <div id="footer"><p>© 2013 VeganFoodPyramid.com</p></div>
    
    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    try {
    var pageTracker = _gat._getTracker("UA-6992755-1");
    pageTracker._trackPageview();
    } catch(err) {}</script>
    
    </body>
    </html>
    

    Merged Footer (footer.php)

    
    <div id="footer"><p>© <?php echo date('Y'); ?> VeganFoodPyramid.com</p></div>
    
    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    try {
    var pageTracker = _gat._getTracker("UA-6992755-1");
    pageTracker._trackPageview();
    } catch(err) {}</script>
    
    <?php wp_footer(); ?>
    
    </body>
    </html>
    

    Explanation

    Some footers are hard to migrate (such as ones with complex menus and widgets), but most are simple. In this case, we’ve merged the HTML with our footer template, making sure to preserve our reference to the wp_footer hook. We’ve also changed the date reference to use PHP, ensuring that it updates with each year.

    4. Home Page

    One of the challenges of a migration is that there are so many different ways to get the job done. The home page is a good illustration of this because it tends to be the most different from the rest of the website. Adopting the simplest method is usually best. I’ve opted to put all of the home page’s content directly in the template. Changes will be rare and can easily be made by editing the template.

    Let’s look at the code, excluding the header and footer, which we’ve already covered.

    Original HTML

    
    <div id="content">
    
    <div id="poster">
    <a href="http://veganfoodpyramid.com/images/Vegan-Food-Pyramid-New.jpg"><img class="product-img" src="http://veganfoodpyramid.com/images/Vegan-Food-Pyramid-New.jpg" /></a>
    <div class="description">
    <h2>Poster</h2>
    <p>A 30×20-inch poster illustrating over 125 vegan food items as an alternative to the traditional food pyramid. This poster will catch people’s attention and serve as a suggestion for food ideas.</p>
    <h3>$30 each</h3>
    <p>Includes free shipping worldwide</p>
    <a class="button" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2FKQT879CXYYG">Buy</a>
    </div>
    </div>
    
    <div id="postcard">
    <a href="http://veganfoodpyramid.com/images/Vegan-Food-Pyramid-New.jpg"><img class="product-img" src="http://veganfoodpyramid.com/images/postcard-splash.jpg" alt="Postcard Splash" /></a>
    <div class="description">
    <h2>Postcards</h2>
    <p>Beautiful 4×6 postcards that can be mailed and shared with friends and family. Hand them out at events. Post them on walls. Share the vegan love!</p>
    <h3>$50 for 50</h3>
    <p>Includes free shipping worldwide</p>
    <a class="button" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=EN387WHNSSFMW">Buy</a>
    </div>
    </div>
    
    </div> <!-- end content -->
    

    Merged Home Page (/page-templates/front-page.php)

    
    <?php
    /**
     * Template Name: Front Page Template
     */
    
    get_header(); ?>
    
    <div id="content">
    
       <div id="poster">
          <a href="/<?php echo get_stylesheet_directory_uri(); ?>/images/Vegan-Food-Pyramid-New.jpg"><img class="product-img" src="/<?php echo get_stylesheet_directory_uri(); ?>/images/Vegan-Food-Pyramid-New.jpg" /></a>
          <div class="description">
             <h2>Poster</h2>
             <p>A 30×20-inch poster illustrating over 125 vegan food items as an alternative to the traditional food pyramid. This poster will catch people’s attention and serve as a suggestion for food ideas.</p>
             <h3>$30 each</h3>
             <p>Includes free shipping worldwide</p>
             <a class="button" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2FKQT879CXYYG">Buy</a>
          </div>
       </div>
    
       <div id="postcard">
          <a href="/<?php echo get_stylesheet_directory_uri(); ?>/images/Vegan-Food-Pyramid-New.jpg"><img class="product-img" src="/<?php echo get_stylesheet_directory_uri(); ?>/images/postcard-splash.jpg" alt="Postcard Splash" /></a>
          <div class="description">
             <h2>Postcards</h2>
             <p>Beautiful 4×6 postcards that can be mailed and shared with friends and family. Hand them out at events. Post them on walls. Share the vegan love!</p>
             <h3>$50 for 50</h3>
             <p>Includes free shipping worldwide</p>
             <a class="button" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=EN387WHNSSFMW">Buy</a>
          </div>
       </div>
    
    </div> <!-- end #content -->
    
    <?php get_footer(); ?>
    

    Explanation

    The front-page.php template begins and ends with a reference to the header and footer that we’ve just prepared. In between, we’ll merge the rest of the HTML, and we’ll use the get_stylesheet_directory_uri function, which will dynamically generate references to the images folder in our new theme.

    5. Standard Page Template

    With the header and footer done, the standard templates are usually quite easy. For brevity’s sake, we’ll go directly to the merged templates.

    Merged Template (page.php)

    
    <?php
    /**
     * The template for displaying all pages.
     */
    
    get_header(); ?>
    
    <div id="content">
    
       <?php while ( have_posts() ) : the_post(); ?>
    
          <?php get_template_part( 'content', 'page' ); ?>
       
       <?php endwhile; ?>
    
    </div>
    
    <?php get_footer(); ?>
    

    Content Template (content-page.php)

    
    <?php
    /**
     * The template used for displaying page content in page.php
     */
    ?>
    
       <article <?php post_class(); ?>>
          <?php the_content(); ?>
       </article>
    
    

    Explanation

    There are several items to point out here:

    • The loop
      If you’re new to WordPress or programming in general, this piece of code in the #content container might look intimidating. The “loop” is code used by WordPress to display a post’s content. You can learn more about the loop in the Codex. Meanwhile, just make sure that it’s in there, or else the content you save in WordPress won’t show up.
    • get_template_part
      Our page template here employs the handy get_template_part function, which is a great way to keep content organized, especially in complex projects. Our website is simple enough not to warrant it, but I left it in just to show you.
    • post_class
      I also added a reference to <article> (with the corresponding post_class function) to make further customization of the design easier.

    5. Full-Width Template (full-width.php)

    Although not illustrated in the screencast, the design includes a full-width template for use on the “Wallpaper” page, while the standard page template is changed to a narrow width.

    Let’s have a look.

    Merged Template (templates/full-width.php)

    
    <?php
    /**
     * Template Name: Full-Width Template
     */
    
    get_header(); ?>
    
    <div id="content" class="full-width">
    
       <?php while ( have_posts() ) : the_post(); ?>
    
          <?php get_template_part( 'content', 'page' ); ?>
       
       <?php endwhile; ?>
    
    </div>
    
    <?php get_footer(); ?>
    

    Explanation

    With the template created, all that remains is to assign it to a page. From the “Edit Page” interface, find the “Page Attributes” box (usually right below the “Publish” box) and select “Full-Width Template” from the “Templates” dropdown menu.

    6. Extras

    Now let’s tackle some of the “extras” that sometimes come up as challenges during a WordPress migration.

    • Breadcrumbs
      Breadcrumbs are relatively common on websites. The easiest way to reproduce them is with a plugin. My current favorite is Breadcrumb NavXT (free). WordPress SEO also offers built-in breadcrumbs.
    • Widgets
      If the design you’re migrating has a sidebar, you could either reproduce it as is (the migration theme has a sample sidebar in place) or integrate WordPress widgets to allow for a dynamically managed sidebar. The folks at Automattic have prepared a handy guide to widgetizing themes. Start there.
    • Restricted content
      In case some content needs to be restricted, WordPress offers basic password protection by default. If you want more control, use a plugin. For basic role management and content permissions, I recommend Members (free). For more advanced control (especially if payment is involved), consider Membership (which has basic and premium versions), s2Member (also free and premium) and WP-Members (free).
    • Custom Post Types
      Some migrations, especially ones with a lot of different types of content, call for “custom post types.” You can learn about custom post types in the Codex. To set them up, I recommend using a plugin. Two good choices are Custom Post Type UI and Types (both free).

    Review Website

    Now that we’ve wrapped up work on the theme, it’s time for a review. Work carefully through the pages on the migrated website. For a large website, focus on the different templates. As you review, here are some things to watch out for:

    1. Broken links
      Make sure all links work as they should. If you have only a few pages, you can check manually. For an automated check, use Integrity (free, for Mac) or Xenu’s Link Sleuth (free, for Windows).
    2. Broken styles
      Occasionally, for one reason or another, a design element of your website might have broken during the migration. Carefully compare the old HTML to the new to make sure you haven’t missed any important code and that the corresponding style sheet rules have been carried over. If all else fails, a quick rebuild of the design element on the new website might be in order.
    3. Broken functionality
      Test any functionality that you’ve migrated over, such as “Buy now” buttons, contact forms, newsletter opt-ins, “members-only” content, embedded maps, media players, etc.
    4. Temporary links
      Depending on how you’ve carried out the migration, temporary links to a subfolder or testing domain might appear in your content or theme. You’ll want to update these before going live. Use the Search and Replace plugin (free) to check for and update links in your content.

    Setting Up Redirects

    If your link structure has changed (and it usually will, even if only slightly), make sure that visitors are redirected from the old pages to the new. For small amounts of content, one of the easiest ways to set up redirects is by adding them to the .htaccess file.

    Open the .htaccess file in the WordPress directory. If you don’t see it, set your FTP client to show hidden files. Now, create redirect rules for each of the old pages. Be sure to put these rules after WordPress’ block of rules.

    Here are the rewrite rules for our links:

    
    Redirect 301 /wallpaper.php http://veganfoodpyramid.com/wallpaper/
    Redirect 301 /about.php http://veganfoodpyramid.com/about/
    Redirect 301 /contact.php http://veganfoodpyramid.com/contact/
    Redirect 301 /contactthanks.php http://veganfoodpyramid.com/contact/thanks/
    

    If editing your .htaccess file is not an option or if you’re dealing with a lot of redirects, then have a look at Redirection (free).

    Advanced tip: If the volume of redirects is very high (which is likely with a large-scale migration and a custom importing process), then consider building a function that hooks into template_redirect, compares a generated list of cases, and then uses the wp_redirect function to redirect any matches.

    Going Live

    Going live with a website usually involves one of two tasks:

    1. Relocate WordPress from the development folder to the root directory.
    2. Point the domain name from the old server to the new WordPress server.

    Going Live!

    Relocating WordPress

    If you set up WordPress in a subfolder (as we did), then going live involves a few simple steps. Follow the guide to using a pre-existing subdirectory installation.

    Once you’ve made the change, check immediately for any broken links that you may have missed in the final review.

    Pointing to a New Server

    If you set up WordPress on a new server, then you probably used a temporary domain. Accordingly, remove references to the temporary domain before pointing the domain to the new server.

    Also, if you’re planning to update the name servers for your domain, then first resolve any dependencies in the current DNS records (such as hosted email and third-party services). I usually go live with a domain by updating the A records, leaving the name servers in place.

    Conclusion

    And there you have it! A successful WordPress migration is all about the details, and while this guide is by no means comprehensive, you now have a good outline of the process and a sense of some of the challenges you’ll encounter, along with ideas for solving them. If you run into challenges along the way, share them in the comments below. Now get migrating!

    (al)


    © Jonathan Wold for Smashing Magazine, 2013.



  • A Client- And Server-Side Approach: Providing The Best Mobile User Experience Possible

      

    Now and again, I hit the swimming pool. It’s a good way to exercise, but also to relax after a long day in front of my PC. I can do quite a few laps in my front crawl, but only because I don’t use my legs much. I kick steadily to ensure that my legs stay lifted and don’t slow me down. I don’t use my legs much for forward propulsion. An instructor once explained to me that legs can definitely help with propulsion in the front crawl, but only at the cost of much higher energy consumption.

    He also explained that champions use their legs a lot. Their hearts are powerful, and they can happily sacrifice the extra effort for the small yet significant gain in speed. People with modest competitive ambitions are typically better off with moderate leg usage.

    Does this relate to mobile Web development, responsive Web design and server-side device detection?

    The analogy is a stretch, but yes, it does. As the inventor of WURFL, I used to live in a world where mobile devices were so limited in capabilities that there was no way a commercial website and its corresponding mobile website could be supported through a unique set of HTML pages without the support of some server-side logic. Strategies to detect and tweak content for mobile devices varied from simple detection scripts to the adoption of full-fledged device description repositories (DDR) such as WURFL.

    Today, things have, to a large extent, changed. Many still have a feature phone, but the majority of users who care about accessing the Internet from their mobile devices will have a smartphone. A 2013 smartphone means the following: a fast connection, a great WebKit-based browser, a 320-pixel wide (or wider) touchscreen and a great operating system that allows for the installation of apps.

    This evolution has turned the mobile Internet into a swimming pool available to every webmaster. Programming strategies such as progressive enhancement (PE) and responsive Web design (RWD) enable everyone to make their full websites usable enough on smartphones from a single set of HTML pages — i.e. with no need for server-side device detection. This is awesome. Webmasters can now make their websites more mobile-friendly without introducing a significant amount of extra complexity. Yet, just like in my initial analogy, the saving is only achieved at the cost of sacrificing certain aspects of the mobile UX that “champions” would not be OK with sacrificing.

    In a previous article by Ronan Cremin and me, “Server-Side Device Detection: History, Benefits and How-To,” we explored the different aspects of client-side approaches versus server-side approaches, and we concluded that server-side strategies still offer a lot to mobile Web developers. I won’t repeat it here; rather, I will go one step further and explain how the two worlds can happily coexist for everyone’s benefit.

    Client-Side Vs. Server-Side: A False Dichotomy

    Most IT people are familiar with the saying, “When all you have is a hammer, every problem looks like a nail.” This is perfectly applicable to mobile development, where, in my experience, developers with a JavaScript and CSS background tend to favor client-side solutions to the problem of device diversity, while developers with traditional system development skills find server-side approaches more natural.

    Unsurprisingly, there are pros and cons to both approaches, and, more importantly, the two approaches are not mutually exclusive and can be made to work together. After all, for any organization that offers a website, the ultimate purpose is to create the greatest user experience possible for its users within the constraints of the project’s timeline and budget.

    Best Of Both Worlds

    When it comes to building a strategy for a website that is friendly to mobile users, there is a whole range of possibilities. At one extreme, a designer might adopt a purely responsive website because they cannot afford to maintain a server-side detection component (or simply because they do not find enough value in the extra complexity). At the other extreme are large companies whose websites (and mobile websites) address particular quirks of popular devices. This approach requires an investment and dedicated team so large that typically only major Internet companies (think Facebook, Yahoo and Google) would go for it.

    Most other companies will find the optimum point somewhere between the two extremes by segmenting the world of connected users in ways that make the most sense in their markets. Such segmentation will need to rely on some form of server-side detection.

    One way to put it is that one should adopt a “best of both worlds” hybrid approach. In this article, I will show an example of this.

    Every software project is one-off. The Web is no exception. Nor is mobile Web development, where the super-rapid progress of mobile devices is constantly turning best practices into moving targets. For this article, I figured that nothing could make the point better than a real example with real code.

    My example is a cross-browser and cross-device slideshow. I will show how server-side and client-side detection can be made to work together to deliver a great UX on a variety of clients.

    Segmentation (Good Ol’ Divide And Conquer)

    The slideshow will be made available to the following classes of HTTP clients:

    • non-smartphones (or feature phones),
    • smartphones,
    • tablets and desktops.

    I have always called these “segments,” and I have referred to the splitting up into segments as “segmentation.” The key point is that each segment will be provided with a fundamentally different UI structure. Such segmentation will be supported through server-side detection.

    Within each segment, there will still be space for further optimization of the UX. Such optimizations will happen with RWD and device detection. Notably, this approach will be used to obtain pictures in different sizes and to address the bandwidth problem, particularly for mobile devices.

    Let’s start by sketching the different UIs for the different classes of HTTP clients (i.e. segments).

    Non-Smartphones

    Non-smartphones are commonly referred to as feature phones in the industry. There is no standard definition of what a smartphone is, but a device that possesses the following features would likely be called a smartphone by most:

    • touchscreen;
    • a screen that is 240-pixels wide or wider;
    • Android 2.2, iOS, Windows Phone 7.5 or higher, RIM OS 7 or higher, Symbian Belle or higher, Nokia N9 WebKit-based browser;
    • not a tablet.

    This is a totally arbitrary definition, but good enough for the purpose of this article.

    Devices that do not support one or more of the above features will be considered feature phones.

    Because no assumption can be made for non-smartphones, we will assume a small screen, no touchscreen and limited bandwidth (which entails the need to minimize the number of HTTP requests required to download all of the content).

    Please note that the lack of a touchscreen might require users to click the “down” button multiple times to get to the icon they wish to select.

    The following wireframe nicely illustrates what we are getting at:

    feature phone view
    Feature phones (i.e. non-smartphones) have relatively small screens (typically narrower than 240 pixels). The presence of a touchscreen should not be assumed for devices in this segment.

    Smartphones

    Smartphones have a large screen, and users don’t have to click their way through icons to get to the one they want. They simply touch it. Because of this, a UI such as the following is better suited to them:

    smartphone view
    Smartphones have large screens (240 pixels or wider). The presence of a touchscreen and of basic media queries for changes in orientation may be safely assumed.

    Tablets and Desktops

    In the case of tablet and desktop browsers, we can safely assume that a large screen is available. In this case, consolidating the two views (i.e. the navigation and the actual picture) into a single screen makes sense:

    tablet view
    A screen 700 pixels wide (or wider) may be assumed.

    Of course, I created a single segment for tablets and desktops for illustrative purposes, but a real project might segment differently, based on the business model of the organization and the traffic it sees from different classes of devices.

    Before delving into the code to implement this, I should discuss a few aspects of mobile development.

    Important Note About Mobile Bandwidth: Speed Isn’t Everything

    US carriers (i.e. network operators) boast in their advertising about their increasingly faster 4G networks and the blazing download speeds that their customers can get. My experience (and the experience of others) is that those figures are sometimes truthful under good network conditions, as in the case of a large single download or of video streaming. In practice, things are a bit more complicated. The overhead of establishing an HTTP connection in mobile is high.

    Many browsers and devices open only one or two concurrent connections with the server (partly because of what the HTTP specification says, and partly because of hardware limitations). Keep-alives cannot be assumed to always work as one would expect in mobile, because of strategies that the devices follow to save battery power.

    The problem is at the lower levels and is rooted in the fact that mobile networks and TCP/IP were not built to play well together to begin with.

    Techniques such as “domain sharding” (i.e. fooling the browser into believing it’s talking to different servers) help to increase the number of concurrent connections. However, if you want to increase the download speed (both real and perceived) of a website, limiting the overall number of HTTP connections is your best bet.

    May Your Days Be Merry And Your URLs Unique

    People share links on Twitter, Facebook, Google+ and a lot of other services these days. This is good, but it has also exposed a shortcoming with a popular approach to managing the mobile channel — i.e. creating a separate mobile website (with separate URLs to the mobile view of the content). In short, a user will share http://m.coolsite.com on Twitter, and users on desktops and tablets will be offered a sucky UI. Having http://www.coolsite.com serve both the Web and mobile experience would effectively solve the problem.

    As my last article explains, there are ways to have a single URL “multi-serve” content for different media. Of course, this requires a bit more design and work from the service architect as compared to purely client-side approaches.

    In the case of PE and RWD, the “uniqueness” of the URL comes free of charge. In the case of server-side detection, a strategy to multi-serve content from a unique URL needs to be designed into the system. We will see one way to achieve this in the code discussed further down.

    Content = Content + Presentation? A Little (But Important) Aside

    Ethan Marcotte, arguably the inventor of RWD, correctly identifies the URL issue in his book Responsive Web Design:

    “I do think fragmenting our content across different “device-optimized” experiences is a losing proposition, or at least an unsustainable one.”

    This sentence has been quoted endlessly, and it seems hard to disagree with. Yet, it contains an ambiguity that makes it very debatable, to say the least. What Ethan calls “content” has historically been referred to as “presentation” by most. In fact, I could easily argue that separation of content and presentation is the foundation of a plethora of Web programming frameworks, such as model-view-controller (MVC), but also Windows DNA in the late ’90s.

    While I am aware that designers will argue that the difference between content and presentation is blurry (advertising is the best example of this), such a differentiation has been very helpful to Web programmers in multiple ways over the past 15 years. In general, professionals are much better off preserving this separation, rather than blurring the difference between the two.

    Software architects should obviously not fragment the content managed by their system. At the same time, they should be ready to multi-serve the presentation of the same data to users of different media and different devices in the name of an optimal UX. I would go so far as to argue that PE and RWD are also about providing multiple presentations of the same content, inasmuch as the clever use of grids and media queries allows developers to confine the “multi-serving framework” to a single page.

    End of the aside.

    Getting back to URL uniqueness, it is obvious that, in the case of server-side detection, a URL strategy must be designed with extra use of resources. Of course, webmasters have managed similar issues all their careers. Internationalizing a website presents the same challenges: one could have content served in multiple languages from the same URL (or even JSP or PHP page) or simply provide sibling websites, one for each supported language. Support for the potential lack of JavaScript presents a similar issue, as does the fact that an international content provider may wish to offer different (i.e. more relevant) content to visitors from different geographic regions, even where the language is the same. Supporting this means extra effort and cost. Typically, after the cost versus benefit equation is solved, some companies will go for the benefit in spite of the cost.

    After so many words, let us see how the following code implements everything we’ve illustrated above.

    The Code

    Everything that has been discussed so far is illustrated in practice with a self-contained example that I built (along with my friend Steve Kamerman, COO at ScientiaMobile) to reinforce the points in this article. Be aware that, for the sake of clarity, the example hardwires many of the resources that would normally be isolated in separate databases or configuration elements.

    Here is a list of the main components in the code:

    • a DDR;
    • an MVC framework;
    • a controller with the segmentation logic;
    • a server-side image-resizing framework;
    • the views — feature phone, smartphone and tablet/desktop, in our case.

    Let’s discuss each of them.

    Device Description Repository

    A DDR is a software framework that enables an application to associate an HTTP request with the properties of the client (Web browser, mobile device, Internet-enabled wristwatch, etc.). In our example, I will be using ScientiaMobile’s DDR, WURFL Cloud, because it’s the easiest to install on all platforms and also comes with a free offering for those who want to play around with it.

    Of course, any other DDR could be used in place of WURFL Cloud, including AGPL-licensed WURFL or other open-source frameworks based on user-agent string analysis through regular expressions.

    For the purpose of this article, here is the core bit of code that explains how to use the DDR (in the index.php file):

    :
    require_once dirname(__FILE__).'/lib/WurflCloudClient/Client/Client.php';
      :
    
    // Disable caching for testing
    $cache_enabled = false;
    
    $wurfl_config = new WurflCloud_Client_Config();
    $wurfl_config->api_key = 'XXXXX:YYYYYYYYYYYYYYYYYYYYYYYYYYY';
      :
    if ($cache_enabled) {
    	$wurfl = new WurflCloud_Client_Client($wurfl_config);
    } else {
    	$wurfl = new WurflCloud_Client_Client($wurfl_config, new WurflCloud_Cache_Null());
    	header("Cache-Control: no-cache, must-revalidate");
    	header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
    }
    $wurfl->detectDevice();
    

    Note: The cache is disabled because this is handy for testing purposes. But you’ll want to enable it on a production website, or else every HTTP request from your users will be a request to the cloud.

    Once this code has run, you will be able to look up device capabilities on your server, without any need to interact with the client through JavaScript or the like, as simply as this:

    
    $wurfl->getDeviceCapability('is_tablet')
    

    All of the magic of looking up the HTTP request and recovering a profile for the device is happening under the hood.

    Model-View-Controller Framework

    MVC is a popular programming pattern among Java developers that over the years has made inroads among programmers of other languages (including PHP). In short, the MVC framework analyzes an incoming HTTP request and “dispatches” the actual handling to a different PHP page that has been deemed to be more apt for the job. In our case, the framework will route the HTTP request to the PHP page that would implement the best UI for that “segment.”

    For the record, the MVC framework we’re using in our example is homemade, but Steve explains that it was inspired by a micro-framework named Silex.

    The framework itself is implemented in the lib/SimpleApp.php file:

    
    require_once dirname(__FILE__).'/lib/SimpleApp.php'; 
      :
    $app = new SimpleApp();
    

    Once the MVC framework is included, dispatching an HTTP request to the right view (see below) is as simple as this:

    
    $app->render('image/smartphone.php', $view_data);
    

    The interesting part is that the URL will not be affected by this. Users will only see the index.php page that responded to the request. This effectively solves the problem of URL uniqueness that we discussed above.

    Controller

    The controller (the “C” in MVC) is in charge of segmentation (i.e. deciding the view to which a certain HTTP client should be directed based on its profile). Here is the core of the controller (in index.php):

    
    if ($wurfl->getDeviceCapability('is_smartphone')) {
    	$app->render('index/smartphone.php', $view_data);
    } else if ($wurfl->getDeviceCapability('is_mobile') 
    && !$wurfl->getDeviceCapability('is_tablet')) {
    	$app->render('index/featurephone.php', $view_data);
    } else {
    	$app->render('index/desktop.php', $view_data);
    }
    

    In light of what we have explained, this part should be rather self-explanatory: smartphone.php handles smartphones, featurephone.php handles feature phones, and everything else (including tablets) is handled by desktop.php. There are actually two sets of views, one that manages the discovery page (i.e. the thumbnails with pictures) and one that represents the single picture.

    The is_smartphone capability is a so-called “virtual capability” — i.e. a computed property that relies on other capabilities and that represents ScientiaMobile’s understanding of what a smartphone is. A lot of people find this handy. Of course, nothing prevents a WURFL user from choosing the capabilities and rolling a particular segmentation that make the most sense for their business model.

    Image Resizing (RESS)

    RESS stands for “responsive images and server-side components,” making it the most screwed-up abbreviation I have ever seen in my life. Because it is now common, though, I will use it, too. The premise of RESS is fairly reasonable: RWD is cool, but sending 500 KB pictures to a mobile device is not a good idea for a variety of reasons. This is why even the most inveterate RWD promoters will concede that resizing pictures on the server in order to speed up downloading and rendering on mobile devices is still a good idea. Of course, CSS and JavaScript files are also resources that you’ll want to make as light as possible. These also fall under the RESS umbrella.

    Users of WURFL Cloud also have access to a service called Image Resizer. In short, Image Resizer enables you to create a URL that piggybacks the following bits onto itself:

    • the URL of the original picture,
    • a combination of parameters that specify how the picture should be resized and manipulated.

    Requesting the URL will result in a picture with the desired features being obtained. For the record, other services of this kind are around, such as Sencha.io Src and the up-and-coming WhateverWeb, which promises to go beyond simple image resizing. Call me a romantic, but I prefer that we eat our own dog food for this example.

    A photographer also graciously gave me some pictures of Chicago for this article, which I’ve hosted at http://cto.scientiamobile.com/chicago/ (i.e. in a place where Image Resizer can pick them up):

    Let’s see how Image Resizer is used in practice (see views/index/smartphone.php):

    
    // Compute the size of the image thumbnails
    $thumb_width = 95;
    $thumb_height = 95;
    $rszr_tumbnail = "http://rszr1.wurflcloud.com/234341/w_$thumb_width/
                      h_$thumb_height/m_cropbox/";
      :
    <div style="width: 100%; float: left; margin: 5px;">
      <?php foreach ($images as $id => $image) { ?>
       <div style="float: left; margin: 5px;">
          <a href="/<?php echo $app->getUriPrefix().'/image/'.$id; ?>">
            :
           <img alt="" src="/<?php echo $rszr_tumbnail.$image['src']; ?>" />
          </a>
        </div>
      <?php } ?>
    </div>
    

    This will generate markup like the following snippet:

    
    <div style="float: left; margin: 5px;"><a href="/smash/image/1"><img alt="" src="http://rszr1.wurflcloud.com/234341/w_95/ h_95/m_cropbox/http://cto.scientiamobile.com/chicago/chicago2.jpg" /></a></div>
    

    In reality, I’ve cheated a bit. I cut some interesting bits from the code above. In particular, I’ve removed a trick to use a really important technique called the data URI scheme, which enables developers to nest pictures in the HTML itself in the form of ASCII Base64 garbage. As you can imagine, not all devices support the feature (although smartphones usually do). This is where WURFL’s image_inlining capability, along with the ability of the image resizer to provide the picture already in Base64 format, comes in handy. The image_inlining will tell you whether the data URI scheme is supported:

    
    $image_inlining = $wurfl->getDeviceCapability('image_inlining');
    if ($image_inlining) {
    	$rszr_tumbnail = "http://rszr1.wurflcloud.com/234341/w_$thumb_width/
                             h_$thumb_height/m_cropbox/in_true/"; } else {
    	$rszr_tumbnail = "http://rszr1.wurflcloud.com/234341/w_$thumb_width/
                             h_$thumb_height/m_cropbox/";
    }	
      :
    <div style="width: 100%; float: left; margin: 5px;"<
    <?php foreach ($images as $id => $image) { ?>
      <div style="float: left; margin: 5px;">
        <a href="/<?php echo $app->getUriPrefix().'/image/'.$id; ?>">
        <?php if ($image_inlining) { ?>
          <img alt="" src="/<?php echo file_get_contents($rszr_tumbnail.$image['src']); ?>"/> 
        <?php } else { ?>
          <img alt="" src="/<?php echo $rszr_tumbnail.$image['src'];?>"/> 
        <?php } ?> 
      </a></div>
    <?php } ?>
    </div>
    

    In the case of a device that supports image inlining, the code above will produce the following:

    
    <div style="float: left; margin: 5px;">
    <a href="/smash/image/1"> <img alt="" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD//gA7Q1JFQVRPUjogZ2QtanBlZ..
      :
    AUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlN
       : 
    cH14z9RXHTc6jb6dWdM3GmrdT//Z" /> </a>
    </div>
    

    As we discussed earlier, this is particularly crucial because of the importance of minimizing the number of HTTP requests demanded by a mobile device to download a page, an aspect that is simply not worth optimizing in classic Web programming: too much extra work for way too little gain.

    Of course, the data URI scheme will greatly increase the perceived download speed on smartphones and non-smartphones alike.

    The Views: Feature Phone, Smartphone and Desktop/Tablet

    The three segments we initially defined map one to one with our three views (feature phone, smartphone and tablet/desktop), according to the MVC paradigm. Each view offers a user experience that is best suited to the respective class of devices and browsers.

    It goes without saying that adopters of a DDR still retain control over the UX of a deployed application simply by configuring a device to access a given view (for example, by downgrading a misbehaving smartphone to the feature-phone view).

    The feature-phone view is particularly interesting because you’ll want to serve XHTML Mobile Profile (XHTML MP) as a markup to those devices. Developers who approach mobile today might get away with ignoring XHTML MP, but for years XHTML MP has been the standard mobile Web markup. Still today, smartphones will immediately recognize a website created in XHTML MP as being a mobile website, even when no viewport meta tag is available. Be aware that XHTML MP is typically better served with a different MIME type than text/html.

    Note: Covering XHTML MP is beyond the scope of this article. If you are curious about the world of mobile programming on feature phones, my document “Global Authoring Practices for the Mobile Web” enjoyed some popularity for some time. Most people find it very informative still today.

    The following screenshots visualize what the different UIs mean in practice:

    Feature Phones
    The view on feature phones.

    View on smartphones
    The view on smartphones.

    Tablet
    The view on tablets and desktop. Above: The page on an iPad.

    Xbox (MSIE 10)
    Here is the same page on the Xbox 360 (IE 10).

    Of course, this example is just a proof of concept. Nothing prevents a programmer from making the desktop view even more responsive than it already is, or from adopting something like the good PhotoSwipe to provide interactive slideshows on smartphones and tablets (but not on older phones, where they would be unlikely to work). Divide and conquer.

    Conclusion

    Purely client-side approaches such as RWD and PE can make Web pages accessible on smartphones. For companies and organizations, this means that supporting mobile devices could be cheaper now than it was a couple of years back. Yet, these savings come at the cost of sacrificing certain aspects of a full-fledged cross-channel Web offering.

    Large organizations may still want to adopt server-side device detection in some form to deliver a great UX to everyone who accesses their websites. While RWD and PE strategies can (and should) be adopted by companies, a hybrid client- and server-side approach is the most likely to deliver a great service to desktop, tablet and mobile users alike.

    We’ve discussed an instance of such a hybrid approach by showing how segmentation, server-side resized images and the data URI scheme are key components to a great user experience across devices and browsers.

    Have a look at the demo app.

    (al) (ea)


    © Luca Passani for Smashing Magazine, 2013.



  • Fables, Myths And Narratives: Converting Our Stories Into Multi-Screen Experiences

      

    Storytelling takes many forms. In the past, stories were told orally, with people telling and retelling myths, fables and even histories. As writing technology became more prevalent, we began to record our stories, and we told them in the pages of books. Now, our society is awash in different devices and technologies, and those traditions of spoken stories and printed stories are blurring.

    Multi-screen narratives are being told across all kinds of platforms, pages and devices, making for truly immersive experiences. We are watching them, tapping them and learning from them. They immerse us in the storyteller’s world. This article outlines what I believe are the five essentials of telling multi-screen stories.

    How I Fell In Love With Interactive Storytelling

    First, a little background. My childhood was spent in Nigeria, West Africa. I am a member of the Tiv tribe, a group of about 6 million people clustered in Nigeria’s Benue River Valley. As a child, I heard a lot of Nigerian folktales, about animals, humans and even magic. In Nigerian narrative tradition, stories are often told orally, in front of a gathered audience. During festivals and cultural events, men even dress up in elaborate costumes and perform stories for the crowds. I have vivid memories of these stories and have always been curious about how they could be translated into something digital and interactive.

    kwagh-hir-nigerian-masquerade
    The Kwagh Hir, or Thing of Magic, my tribe’s largest cultural festival (Image: Naptu2)

    Those fables are a piece of my cultural inheritance. They always seemed to contain essential truths about humans. Take the story of the Ear and the Mosquito. One day, the Ear steals food from the Mosquito and refuses to pay it back. In anger, the Mosquito visits the Ear every evening, demanding the food to be returned, annoying Ear all night with his buzzing. It’s an old tale, with many versions, but the moral is consistent: don’t steal from your friends.

    Creating modern, interactive versions of these stories is possible, but how exactly do we do that? Let’s begin by talking about what I mean by the word “multi-screen.”

    A Bit About Context And Screens

    When speaking about multi-screen storytelling, remember that screens have different contexts, not only different capabilities. The same screen on which you carelessly watch videos at home becomes a closely guarded viewport when you’re watching a movie on a crowded train. The context in which people view stories is more important than the device’s specifications. When we tell interactive stories, we need to be aware of this, and embrace it.

    I like to focus on the following screens:

    • Sensors (Twine, GPS, Arduino, motion detectors, etc.)
    • Mobiles and tablets (phones, tablets, laptops and everything in between)
    • Flat-screens (desktops, TVs, etc.)
    • Public and immersive displays (store kiosks, large stadium screens, projectors, Kinects, etc.)

    Not all of these need to be used at the same time, because they won’t all be appropriate to the story you are telling. Context is extremely important.

    Now, as promised, here are the five essentials of multi-screen storytelling.

    1. Divide Your Story Into Separate Content Blocks

    When we create multi-screen narratives, we need to find natural breakpoints in the story, places where the visual or narrative content can easily be separated. This enables us to deliver different segments to different devices, in different contexts.

    Kolobok is a Slavic children’s story about the adventures of a round yellow cake. For the Moscow International Festival, a large team of designers and animators from SilaSveta Studio incorporated it into a truly fascinating demonstration of storytelling. Before the show, the team set up a large touchscreen at the children’s height. With their hands, the kids could manipulate parts of the animation by adding movement and color.

    kolobok-story-on-touchscreen
    A public display for children to play with

    For the show itself, the full story was projected onto the facade of a large building, allowing the crowd of adults and their children to watch the narrative unfold. Along with sound, it made for another discrete content block, one that closely resembled a 3-D movie.

    kolobok-story-on-building
    The full animated story in front of a large festival crowd

    While the touchscreen and the movie were different views of the same content, they could exist as independent pieces and did not have to appear next to each other. The SilaSveta team found the natural breakpoints in its story and created two separate visual experiences to match them.

    Questions to Ask

    • Where are the breakpoints in the story? Divide your content so that it makes sense in context. The practice of responsive design gives us numerous guidelines on how to do this.
    • Can those content blocks exist independently? Sometimes, the answer is no, but it depends on the story. In the Kolobok example above, they can. In other interactive stories, such as Snow Fall from the New York Times, the blocks are chapters in a single story and should be kept together.

    2. Offer People Multiple Perspectives

    Bear 71 is an award-winning multi-screen experience created by Jeremy Mendes and Leanne Allison. The creators tell the story of a bear living in Banff National Park in Canada. It feels like a cross between a role-playing game and a TV documentary, and as a linear narrative with a non-linear interface, it works beautifully.

    bear71-story-site
    The Bear 71 story is told in a highly abstracted interface.

    Multiple viewpoints are accessible. Online, you roam in a stylized landscape, watch crittercam footage from the forest, and otherwise live as bears do — freely. Even though it may look like a game interface, you are not so much “playing” as you are participating in a story. Watching real crittercam footage, you see what the forest silently sees. You also have the option to turn on your webcam (“stealth mode”) to see other users around the world, all watching the same story online.

    bear71-AR-installation

    During shows and installations, the team responsible for Bear 71 set up augmented-reality applications and motion-detection cameras, so that visitors could experience what it’s like to have their pictures taken with one. By playing with the augmented-reality apps and the motion-detection cameras at the installations, users got a bit of the same physical experience that the bears had.

    Questions to Ask

    • Does the narrative change when viewed from a different perspective? A variety of perspectives can make a narrative much more fascinating. Bear 71 forces us to see the world first from the bear’s perspective and to sympathize with its loss of habitat, but other viewpoints take a slightly different angle. The voyeurism common in our digital sharing culture takes on a different meaning when used for animal surveillance.
    • What data sets can be used in the narrative? Bear 71 cleverly combines crittercam video, GPS data, cell tower data, augmented reality, and topographical data. The photographs of visitors to the installation provide an additional emotional layer of data. The data we bring into our stories helps to define additional viewpoints and characters.

    3. Redefine A Tradition

    As Western culture has moved more deeply into Nigeria, Nigeria’s traditions are weakening. I wanted to take a piece of my culture and put it in the cloud, instead of leaving it locked in the heads of our oral storytellers. That meant redefining how the stories are relayed, how they are saved and, most importantly, what messages they convey to the audience.

    In 2011, I started a project named Pixel Fable in which I take those traditional stories and reinterpret them online. In essence, I’m creating an interactive archive of Nigerian stories. As mentioned earlier, the oral histories of Nigerians are rich, but capturing them and translating them into digital stories means they will reach a wider audience. About 25% of my website’s visitors come from the US, while another 25% come from Japan. Canada, France and Germany also send a fair amount of traffic.

    Pixel Fable uses responsive websites, iOS apps and augmented-reality animations to reinterpret Nigeria’s oral history.

    pixel-fable-logo
    An introductory screen from “Cricket and Mud Brick,” a new Pixel Fable story built with the Tapestry app

    I’ve relied on two primary contexts to reinterpret the old Nigerian storytelling tradition. The first is people on their tablets and phones, clicking on and reading the stories. The spread of mobile devices makes this inevitable — why not tell African fables in a more accessible context? The second is my attempt to update the moral lessons for our modern age. While the original story of the Ear and the Mosquito may be a funny tale about annoying insects, the lesson can be updated to speak about how mosquitoes spread malaria in Nigeria. There’s room to redefine our old myths for the 21st century.

    Questions to Ask

    • Will people love or hate the reimagined version? Not every fable or myth can (or should) be recreated digitally. However, if people have an emotional reaction to a story that you have designed and pushed out to multiple screens, that is usually a good sign.
    • If people talk about your narrative, will it bring about change in society? Each Pixel Fable story has a message. Most fables do. Some revolve around love triangles, others around the wisdom of elders, and there’s even one about why you shouldn’t get angry at your friends. They are small messages, but put together, they force us to reconsider how we treat the narrative history of people in Nigeria and West Africa.

    4. Immerse People In The Narrative

    The Walking Dead, the famous comic and now TV show, used a polling Web app (AMC’s Story Sync, if you like marketing-speak) to ask viewers questions and show related content as an episode was being broadcast on TV. While the app was simply timed to each scene, it was an experiment in multi-screen storytelling that invited audience participation, not just audience attention. Polling has a gimmicky feel to it, but that probably came about as a result of Hollywood pressure and doesn’t reflect the value of the concept in general.

    walking-dead-story-sync
    Polling and syncing apps extend narratives from the TV to the couch.

    The creators also added mobile gaming to the mix, bringing viewers “into” the story in a completely different way, in different contexts.

    All of these facets of each story’s arc enabled people to immerse themselves in this apocalyptic narrative. Jason Spero of Google notes the need for a seamless experience as users move between devices. Other people, however, say that a second-screen experience can be extremely distracting, forcing viewers to miss key parts of the TV show. It is the opposite of an immersive experience, they say, and is confusing to use. In my opinion, each content block should work independently to avoid putting users in this position.

    Questions to Ask

    • Will people forget where they are? I’ll be the first to admit that this is not always a good thing. I can’t count the number of times that I’ve almost missed my train stop because my head was buried in my phone. Context, not only device capability, is key. Do you want users to get lost in the story or just engage in a manageable chunk?
    • Do the screens you have chosen feel natural? By this, I’m not referring to pixel density. That is simply impossible to control, and if the story if good, it won’t matter anyway. The screens that people choose will depend a lot on the tasks they want to complete, so make your story feel natural for whatever content block they are interacting with.

    5. Design Contextual Interactions

    Recently, a number of storytelling apps have relied on location to serve additional content, much in the same way that Foursquare or Google Maps do. The Silent History is a dystopian science-fiction story about children who do not speak. The iPad app contains the whole story, but by visiting certain geo-tagged locations, users can access additional content.

    silent-history-story

    For a novel about children all over the US, inviting readers to physically go to where the story’s kids are makes perfect sense. The additional contextual interaction makes the story more layered and thought-provoking, in a way that a simple app would not be.

    We use map data every day, to look for restaurants, check the weather, see road conditions and even check for public transit delays. Other contextual interactions make sense when creating digital stories: taking photographs, texting, sharing and saving information, even body motion. Use these, along with your UI and UX skill sets, to devise new storytelling methods.

    Questions to Ask

    • Does the device matter? With the rise of responsive design workflows, our content should not be device-dependent. Some things, however, such as camera or GPS functionality, may be integral to a part of your story, and so the device would need to be factored in.
    • Should the interface be designed as a seamless part of the narrative? As people who work on the Web, we really have a strength here. If we choose to make the interface part of the story, then we can rely on our experience in building websites and content management systems.
    • Will your story “remember” anything? As a child, I folded over the top corner of the page when I had to put a book down. It was a simple way to keep my place. With a narrative split across multiple devices, it might be necessary to design an interaction that flags where you’ve gotten to and then returns you there when you visit again. That all depends on the content, but the question does need to be asked. Everyone hates losing their place on the Internet and having to navigate back, so perhaps we should enable a memory in our stories as well.

    Conclusion

    We have conceptualized different uses of multiple screens to tell stories. All of us, from every corner of the globe, have intensely rich cultures filled with stories and fables. Using them to create interactive narratives is another way to explore the power of the Web, to wow people and to record our cultural history.

    I would love to see what you come up with, or hear about other examples of clever digital storytelling.

    (al) (ea)


    © Senongo Akpem for Smashing Magazine, 2013.



  • Keeping The Big &lt;picture&gt; Small: How To Avoid Duplicate Downloads In Responsive Images

      

    The <picture> element is a new addition to HTML5 that’s being championed by the W3C’s Responsive Images Community Group (RICG). It is intended to provide a declarative, markup-based solution to enable responsive images without the need of JavaScript libraries or complicated server-side detection.

    The <picture> element supports a number of different types of fallback content, but the current implementation of these fallbacks is problematic. In this article, we’ll explore how the fallbacks work, how they fail and what can be done about it.

    The <picture> Element And Fallback Content

    Like <video> and <audio>, <picture> uses <source> elements to provide a set of images that the browser can choose from. The <source> elements may optionally contain type and media attributes to let the browser know the file type and media type of the source, respectively. Given the information in the attributes, the browser should render the first <source> with a supported file type and matching media query. For example:

    
    <picture>
        <source src="/landscape.webp" type="image/webp" media="screen and (min-width: 20em) and (orientation: landscape)" />
        <source src="/landscape.jpg" type="image/jpg" media="screen and (min-width: 20em) and (orientation: landscape)" />
        <source src="/portrait.webp" type="image/webp" media="screen and (max-width: 20em) and (orientation: portrait)" />
        <source src="/portrait.jpg" type="image/jpg" media="screen and (max-width: 20em) and (orientation: portrait)" />
    </picture>
    

    For situations in which a browser doesn’t know how to deal with <picture> (or <video> or <audio>) or cannot render any of the <source> elements, a developer can include fallback content. This fallback content is often either an image or descriptive text; if the fallback content is an <img>, then a further fallback is provided in the alt attribute (or longdesc), as normal.

    
    <picture>
        <source type="image/webp" src="/image.webp" />
        <source type="image/vnd.ms-photo" src="/image.jxr" />
        <img src="/fallback.jpg" alt="fancy pants">
    </picture>
    

    The <picture> element differs from <video> and <audio> in that it also allows srcset. The srcset attribute enables a developer to specify different images based on a device’s pixel density. When creating a responsive image using both <picture> and srcset, we might expect something like the following:

    
    <picture>
        <source srcset="big.jpg 1x, big-2x.jpg 2x, big-3x.jpg 3x" type="image/jpeg" media="(min-width: 40em)" />
        <source srcset="med.jpg 1x, med-2x.jpg 2x, med-3x.jpg 3x" type="image/jpeg" />
        <img src="/fallback.jpg" alt="fancy pants" />
    </picture>
    

    The idea behind a <picture> example like this is that exactly one image should be downloaded, according to the user’s context:

    • Users with <picture> support and a viewport at least 40 ems wide should get the big image.
    • Users with <picture> support and a viewport narrower than 40 ems should get the med image.
    • Users without <picture> support should get the fallback image.

    If the browser chooses to display the big or med source, it can choose an image at an appropriate resolution based on the srcset attribute:

    • A browser on a low-resolution device (such as an iMac) should show the 1x image.
    • A browser on a higher-resolution device (such as an iPhone with a Retina display) should show the 2x image.
    • A browser on a next-generation device with even higher resolution should show the 3x image.

    The benefit to the user is that only one image file is downloaded, regardless of feature support, viewport dimensions or screen density.

    The <picture> element also has the ability to use non-image fallbacks, which should be great for accessibility: if no image can be displayed or if a user needs a description of an image, then a <p> or <span> or <table> or any other element may be included as a fallback. This allows for more robust and content-appropriate fallbacks than a simple alt attribute.

    The Fallback Problem

    Right now, the <picture> element is not supported in any shipped browsers. Developers who want to use <picture> can use Scott Jehl’s Picturefill polyfill. Also, Yoav Weiss has created a Chromium-based prototype reference implementation that has partial support for <picture>. This Chromium build not only shows that browser support for <picture> is technically possible, but also enables us to check functionality and behavior against our expectations.

    When testing examples like the above in his Chromium build, Yoav spotted a problem: even though <picture> is supported, and even though one of the first two <source> elements was being loaded, the fallback <img> was also loaded. Two images were being downloaded, even though only one was being used.

    This happens because browsers “look ahead” as HTML is being downloaded and immediately start downloading images. As Yoav explains:

    “When the parser encounters an img tag it creates an HTMLImageElement node and adds its attributes to it. When the attributes are added, the node is not aware of its parents, and when an ‘src’ attribute is added, an image download is immediately triggered.”

    This kind of “look ahead” parsing works great most of the time because the browser can start downloading images even before it has finished downloading all of the HTML. But in cases where an img element is a child of <picture> (or <video> or <audio>), the browser wouldn’t (currently) care about the parent element: it would just see an img and start downloading. The problem also occurs if we forget about the parent element and just consider an <img> that has both the src and srcset attributes: the parser would download the src image before choosing and downloading a resource from srcset.

    
    <picture>
        <source srcset="big.jpg 1x, big-2x.jpg 2x, big-3x.jpg 3x" media="(min-width: 40em)" />
        <source srcset="med.jpg 1x, med-2x.jpg 2x, med-3x.jpg 3x" />
        <img src="/fallback.jpg" alt="fancy pants" />
        <!-- fallback.jpg is *always* downloaded -->
    </picture>
    
    <img src="/fallback.jpg" srcset="med.jpg 1x, med-2x.jpg 2x, med-3x.jpg 3x" alt="fancy pants" />
    <!-- fallback.jpg is *always* downloaded -->
    
    <video>
        <source src="/video.mp4" type="video/mp4" />
        <source src="/video.webm" type="video/webm" />
        <source src="/video.ogv" type="video/ogg" />
        <img src="/fallback.jpg" alt="fancy pants" />
        <!-- fallback.jpg is *always* downloaded -->
    </video>
    

    In all of these cases, we would have multiple images being downloaded instead of just the one being displayed. But who cares? Well, your users who are downloading extra content and wasting time and money would care, especially the ones with bandwidth caps and slow connections. And maybe you, too, if you’re paying for the bandwidth you serve.

    A Potential Solution

    This problem needs both short- and long-term solutions.

    In the long term, we need to make sure that browser implementations of <picture> (and <video> and <audio>) can overcome this bug. For example, Robin Berjon has suggested that it might be possible to treat the contents of <picture> as inert, like the contents of <template>, and to use the Shadow DOM (see, for example, “HTML5’s New Template Tag: Standardizing Client-Side Templating”). Yoav has suggested using an attribute on <img> to indicate that the browser should wait to download the src.

    While changing the way the parser works is technically possible, it would make the implementation more complicated. Changing the parser could also affect JavaScript code and libraries that assume a download has been triggered as soon as a src attribute is added to an <img>. These long-term changes would require cooperation from browser vendors, JavaScript library creators and developers.

    In the short term, we need a working solution that avoids wasted bandwidth when experimenting with <picture> and srcset, and when using <video> and <audio> with <img> fallbacks. Because of the difficulty and time involved in updating specifications and browsers, a short-term solution would need to rely on existing tools and browser behaviors.

    So, what is currently available to us that solves this in the short term? Our old friends <object> and <embed>, both of which can be used to display images. If you load an image using these tags, it will display properly in the appropriate fallback conditions, but it won’t otherwise be downloaded.

    Different browsers behave differently according to whether we use <object>, <embed> or both. To find the best solution, I tested (using a slightly modified version of this gist) in:

    • Android browser 528.5+/4.0/525.20.1 on Android 1.6 (using a virtualized Sony Xperia X10 on BrowserStack)
    • Android browser 533.1/4.0/533.1 on Android 2.3.3 (using a virtualized Samsung Galaxy S II on BrowserStack)
    • Android browser 534.30/4.0/534.30 on Android 4.2 (using a virtualized LG Nexus 4 on BrowserStack)
    • Chrome 25.0.1364.160 on OS X 10.8.2
    • Chromium 25.0.1336.0 (169465) (RICG Build) on OS X 10.8.2
    • Firefox 19.0.2 on OS X 10.8.2
    • Internet Explorer 6.0.3790.1830 on Windows XP (using BrowserStack)
    • Internet Explorer 7.0.5730.13 on Windows XP (using BrowserStack)
    • Internet Explorer 8.0.6001.19222 on Windows 7 (using BrowserStack)
    • Internet Explorer 9.0.8112.16421 on Windows 7 (using BrowserStack)
    • Internet Explorer 10.0.9200.16384 (desktop) on Windows 8 (using BrowserStack)
    • Opera 12.14 build 1738 on OS X 10.8.2
    • Opera Mobile 9.80/2.11.355/12.10 on Android 2.3.7 (using a virtualized Samsung Galaxy Tab 10.1 on Opera Mobile Emulator for Mac)
    • Safari 6.0.2 (8536.26.17) on OS X 10.8.2
    • Safari (Mobile) 536.26/6.0/10B144/8536.25 on iOS 6.1 (10B144) (using an iPhone 4)
    • Safari (Mobile) 536.26/6.0/10B144/8536.25 on iOS 6.1 (10B141) (using an iPad 2)

    I ran five tests:

    1. <picture> falls back to <object>
    2. <picture> falls back to <embed>
    3. <picture> falls back to <object>, which falls back to <embed>
    4. <picture> falls back to <object>, which falls back to <img>
    5. <picture> falls back to <img>

    I found the following support:

    What the user sees
    Test 1 Test 2 Test 3 Test 4 Test 5
    Android 1.6 fallback image fallback image fallback image fallback image fallback image
    Android 2.3 fallback image fallback image fallback image fallback image fallback image
    Android 4.2 fallback image fallback image fallback image fallback image fallback image
    Chrome 25 fallback image fallback image fallback image fallback image fallback image
    Chromium 25 (RICG) picture/source image picture/source image picture/source image picture/source image picture/source image
    Firefox 19 fallback image fallback image fallback image fallback image fallback image
    IE 6 no image no image no image no image fallback image
    IE 7 no image no image no image no image fallback image
    IE 8 fallback image no image fallback image fallback image fallback image
    IE 9 fallback image fallback image (cropped and scrollable) fallback image fallback image fallback image
    IE 10 fallback image fallback image (cropped and scrollable) fallback image fallback image fallback image
    Opera 12.1 fallback image fallback image fallback image fallback image fallback image
    Opera Mobile 12.1 fallback image fallback image fallback image fallback image fallback image
    Safari 6 fallback image fallback image fallback image fallback image fallback image
    Safari iOS 6 (iPad) fallback image fallback image fallback image fallback image fallback image
    Safari iOS 6 (iPhone) fallback image fallback image fallback image fallback image fallback image
    HTTP requests
    Test 1 Test 2 Test 3 Test 4 Test 5
    Android 1.6 1 GET 1 GET 1 GET 2 GETs 1 GET
    Android 2.3 1 GET 1 GET 1 GET 2 GETs 1 GET
    Android 4.2 1 GET 1 GET 1 GET 2 GETs 1 GET
    Chrome 25 1 GET 1 GET 1 GET 2 GETs 1 GET
    Chromium 25 (RICG) 1 GET 1 GET 1 GET 2 GETs 2 GETs
    Firefox 19 1 GET 1 GET 2 GETs 2 GETs 1 GET
    IE 6 1 GET none 1 GET 1 GET 1 GET
    IE 7 1 GET none 1 GET 1 GET 1 GET
    IE 8 1 GET none 1 GET 1 GET 1 GET
    IE 9 1 HEAD, 1 GET 1 GET 1 HEAD, 1 GET 1 HEAD, 2 GETs 1 GET
    IE 10 1 HEAD, 1 GET 1 GET 1 HEAD, 1 GET 1 HEAD, 2 GETs 1 GET
    Opera 12.1 1 GET 1 GET 1 GET 2 GETs 1 GET
    Opera Mobile 12.1 1 GET 1 GET 1 GET 2 GETs 1 GET
    Safari 6 1 GET 1 GET 1 GET 2 GETs 1 GET
    Safari iOS 6 (iPad) 1 GET 1 GET 1 GET 2 GETs 1 GET
    Safari iOS 6 (iPhone) 1 GET 1 GET 1 GET 2 GETs 1 GET
    Image-aware context menu
    Test 1 Test 2 Test 3 Test 4 Test 5
    Android 1.6 yes yes yes yes yes
    Android 2.3 yes yes yes yes yes
    Android 4.2 yes yes yes yes yes
    Chrome 25 no no no no yes
    Chromium 25 (RICG) no no no no no
    Firefox 19 yes yes yes yes yes
    IE 6 no no no no yes
    IE 7 no no no no yes
    IE 8 yes no yes yes yes
    IE 9 yes yes yes yes yes
    IE 10 yes yes yes yes yes
    Opera 12.1 yes yes yes yes yes
    Opera Mobile 12.1 yes no yes yes yes
    Safari 6 no no no no yes
    Safari iOS 6 (iPad) no no no no yes
    Safari iOS 6 (iPhone) no no no no yes

    Making Sure The Content Is Accessible

    Although the specifics of how to provide fallback content for <picture> are still being debated (see also this thread), I wanted to test how Apple’s VoiceOver performed with different elements. For these experiments, I checked whether VoiceOver read alt attributes in various places, as well as fallback <span> elements. Unfortunately, I wasn’t able to test using other screen readers or assistive technology, although I’d love to hear about your experiences.

    Read by VoiceOver
    alt on picture alt on source (picturesource) alt on object (pictureobject) alt on embed (pictureembed) alt on embed (pictureobjectembed)
    Chrome 25 no no yes yes no
    Chromium 25 (RICG) yes no no no no
    Firefox 19 no no yes yes no
    Opera 12.1 no no no no no
    Safari 6 no no yes yes no
    Safari iOS 6 (iPad) no no yes yes no
    Safari iOS 6 (iPhone) no no yes yes no
    Read by VoiceOver
    alt on img (pictureobjectimg) alt on img (pictureimg) span (picturespan) span (pictureobjectspan)
    Chrome 25 no yes yes no
    Chromium 25 (RICG) no no no no
    Firefox 19 no yes yes no
    Opera 12.1 no no yes no
    Safari 6 no yes yes no
    Safari iOS 6 (iPad) no yes yes no
    Safari iOS 6 (iPhone) no yes yes no

    Bulletproof Syntax

    Based on these data, I’ve come up with the following “bulletproof” solution:

    
    <picture alt="fancy pants">
        <!-- loaded by browsers that support picture and that support one of the sources -->
        <source srcset="big.jpg 1x, big-2x.jpg 2x, big-3x.jpg" type="image/jpeg" media="(min-width: 40em)" />
        <source srcset="med.jpg 1x, med-2x.jpg 2x, big-3x.jpg" type="image/jpeg" />
    
        <!-- loaded by IE 8+, non-IE browsers that don’t support picture, and browsers that support picture but cannot find an appropriate source -->
        <![if gte IE 8]>
        <object data="fallback.jpg" type="image/jpeg"></object>
        <span class="fake-alt">fancy pants</span>
        <![endif]>
    
        <!-- loaded by IE 6 and 7 -->
        <!--[if lt IE 8]>
        <img src="/fallback.jpg" alt="fancy pants" />
        <![endif]-->
    </picture>
    
    .fake-alt {
        border: 0;
        clip: rect(0 0 0 0);
        height: 1px;
        margin: -1px;
        overflow: hidden;
        padding: 0;
        position: absolute;
        width: 1px;
    }
    

    Here we have a <picture> element, two sources to choose from for browsers that support <picture>, a fallback for most other browsers using <object> and a <span> (see note just below), and a separate <img> fallback for IE 7 and below. The empty alt prevents the actual image from being announced to screen readers, and the <span> is hidden using CSS (which is equivalent to HTML5 Boilerplate’s .visuallyhidden class) but still available to screen readers. The <embed> element is not needed.

    (Note: The use of the <span> as a fake alt is necessary so that VoiceOver reads the text in Opera. Even though Opera has a relatively small footprint, and even though it’s in the process of being switched to WebKit, I still think it’s worth our consideration. However, if you don’t care about supporting that particular browser, you could get rid of the <span> and use an alt on the <object> instead (even though that isn’t strictly allowed by the specification). This is assuming that the <span> and alt have the same content. If you have a richer fallback element, such as a <table>, using both it and a non-empty alt attribute might be desirable.)

    A similar solution should also work with <audio>, although <img> fallbacks for that element are, admittedly, rare. When dealing with <video>, the problem goes away if our fallback image is the same as our poster image. If these may be the same, then the “bulletproof” syntax for <video> would be this:

    
    <video poster="fallback.jpg">
        <!-- loaded by browsers that support video and that support one of the sources -->
        <source src="/video.mp4" type="video/mp4" />
        <source src="/video.webm" type="video/webm" />
        <source src="/video.ogv" type="video/ogg" />
    
        <!-- loaded by browsers that don't support video, and browsers that support video but cannot find an appropriate source -->
        <img src="/fallback.jpg" alt="fancy pants" />
    </video>
    

    However, if your <video> needs a separate fallback and poster image, then you might want to consider using the same structure as the <picture> solution above.

    Note that <video> and <audio> don’t have alt attributes, and even if you add them, they will be ignored by VoiceOver. For accessible video, you might want to look into the work being done with Web Video Text Tracks (WebVTT).

    Unfortunately, extensive testing with <video> and <audio> elements is beyond the scope of this article, so let us know in the comments if you find anything interesting with these.

    How Good (Or Bad) Is This Solution?

    Let’s get the bad out of the way first, shall we? This solution is hacky. It’s obviously not workable as a real, long-term solution. It is crazy verbose; no one in their right mind wants to code all of this just to put an image on a page.

    Also, semantically, we really should use an <img> element to display an image, not an <object>. That’s what <img> is for.

    And there are some practical issues:

    • Chrome and Safari won’t show proper context menus for the images, meaning that users won’t be able to open or save them easily.
    • IE 9 and 10 send an extra HEAD request along with the GET request.
    • Using a <span> as a fake alt is pretty sketchy, and although it worked for my tests in VoiceOver, it could potentially cause other accessibility problems.

    All that being said, as a short-term solution, it’s not too bad. We get these benefits:

    • A visible image in every browser is tested (<picture> and <source> when supported, and the fallback otherwise).
    • Only one HTTP GET request in every browser is tested (and the extra HEAD request and response in IE are tiny).
    • VoiceOver is supported (and is hopefully supported with other screen readers).
    • 
      <!-- show screenshot of network pane here -->
      

    The semantics of the solution, while not ideal, are not horrible either: the HTML5 specification states that an <object> “element can represent an external resource, which, depending on the type of the resource, will either be treated as an image, as a nested browsing context, or as an external resource to be processed by a plugin” (emphasis mine).

    And although the <span> is not as nice as a real alt attribute, using a visually hidden element for accessibility is not uncommon. Consider, for example, “Skip to content” links that are visibly hidden but available to screen readers.

    Next Steps

    The best part about this solution, though, is that it highlights how bad the current situation is. This is a real problem, and it deserves a better solution than the monstrosity I’ve proposed.

    We need discussion and participation from both developers and browser vendors on this. Getting support from browser makers is crucial; a specification can be written for any old thing, but it doesn’t become real until it is implemented in browsers. Support from developers is needed to make sure that the solution is good enough to get used in the real world. This consensus-based approach is what was used to add the <main> element to the specification recently; Steve Faulkner discusses this process a bit in his excellent interview with HTML5 Doctor.

    If you’re interested in helping to solve this problem, please consider joining the discussion:

    The next step towards a long-term solution is to achieve consensus among developers and browser vendors on how this should work. Don’t get left out of the conversation.

    Thanks to fellow RICG members Yoav Weiss, Marcos Cáceres and Mat Marquis for providing feedback on this article.

    (al)


    © David Newton for Smashing Magazine, 2013.



You are here: Designing Today smashing Mag

Ecommerce

If your Business is looking to increase profits by selling products online consider building a shoping cart site. Whether selling 5 products 500, we can design an eye-catching site that will keep your visitors engaged and buying.

 

Your Style

Every Business has it's own style. Whether you are a Beauty Salon or Dentist Office we always take into consideration your particular Style that fits best with your needs.

Social Media

Talk to us about adding Social Media Options to your site, such as...

Search Engine

Search Engine Optimization. We work with you to help your website ranking by submitting your site to the major search engines like Google and Bing. Depending on your buget we can also add addtiional SEO options to your package.

Visit Our Other Sites

Visit our other sites:

  • Coming Soon!

Services

Our Services Include...

  • Web Design & Development
  • Hosting
  • SEO
  • Domain Name Registration
  • Social Media Setup & Design

Green Hosting

We are proud to say we provide "Certified Green Hosting" to our clients. Our Hosting Service has partnered with Green Mountain Energy, the leading provider of cleaner energy and carbon offsetting solutions, to purchase carbon credits to offset the emissions of our hosting operations.

Contact Us

Contact us today to get started on your new Website!