SlideShare une entreprise Scribd logo
1  sur  84
Télécharger pour lire hors ligne
Mobile Web
                                     Development
                              The Challenges and How To Meet Them
                        Tony Thomas - Student Unions & Activities at The University of Minnesota




Tuesday, April 17, 12
Student Unions &
                         Activities 2011 Poll

                        50% have a smartphone
                        7% plan to get one



Tuesday, April 17, 12

Our unscientific student poll.
Tuesday, April 17, 12

Recognize?
Yavin




Tuesday, April 17, 12

This is Yavin, a red giant planet.
Yavin 4                          Yavin




Tuesday, April 17, 12

This is Yavin 4, the location of the rebel base
Student Unions &
                        Activities Website

                              2011: 4.34%




Tuesday, April 17, 12

A snapshot from SUA a year ago.
Student Unions &
                        Activities Website

                            2012: 9.03%




Tuesday, April 17, 12

This year.
Homecoming Website


                              2010: 3.8%




Tuesday, April 17, 12

Homecoming 2010 during the event.
Homecoming Website


                            2011: 11.64%




Tuesday, April 17, 12

Homecoming 2011 during the event.
Spring Jam Website


                               2010: 5.46%




Tuesday, April 17, 12

Spring Jam 2011 during the event.
Spring Jam Website


                             2011: 13.44%




Tuesday, April 17, 12

Spring Jam 2011 during the event.
Mobile Operating
                                   Systems
                 21458
      21500




                            10330




                                          767
                                                           82       56        37        31      6            4
              0
                        S          d              y               e     S          g       ia                      top
                  iO           roi            err               on ianO        sun      ok      LG
                             nd           ckb                Ph      b      am         N                       Hip
                            A
                                       Bla               ows     Sym
                                                                          S
                                                                                                       nge
                                                                                                             r
                                                        d
                                                W
                                                      in                                             Da


Tuesday, April 17, 12

Our users are predominantly iOS & Android. Blackberry distant 3rd. Long tail of others.
Device Dimensions
                                                             Android       Android     Samsung   Nokia                          Android

                                Android                                       Android
                   Android                                                                        Blackberry
                                          Android
                                                     Blackberry
                                                                                                                      Android            Windows
                                                                            Android
                                                                             Android                               Android
                                                                             Android
             Blackberry
                             Android   Android
                                                                  Android                          Android

              Android

                                                                                                 Android
                             Android                                                                                                     Android
                Nokia                                                                                                 Android
                                         Android    iPhone          iPod             Android
                                                                                                                                          Android
                                                                                                 Blackberry
              Samsung
                                                       Blackberry                                              Blackberry    SymbianOS
                                  SymbianOS
                                                                                                                                         Blackberry



Tuesday, April 17, 12

This is just a small sample of device dimensions taken from 1 month of SUA mobile traffic.
Responsive Design

                              Ethan Marcotte




       Photo: Peter J. Hart
       flickr.com/photos/40054618@N03/5140728113/

Tuesday, April 17, 12

This is Ethan Marcotte who introduced the concept of responsive design in 2010.
A Dao of Web Design

                        John Allsopp




       Photo: drewm flickr.com/photos/drewm/
       flickr.com/photos/drewm/4732738890/

Tuesday, April 17, 12

It’s in part inspired by John Allsopp’s 2000 A List Apart article called “A Dao of Web Design.”
A Dao of Web Design

                        alistapart.com/articles/dao/
                        “It’s time to throw out the rituals of the
                        printed page, and to engage the medium of
                        the web and its own nature.”




Tuesday, April 17, 12

[Read quote.] Back in 2000, Allsopp was advocating for embracing the inherent flexible
nature of the web.
Responsive
            Architecture
            “If a building could
            change its posture,
            tighten its muscles
            and brace itself
            against the wind, its
            structural mass could
            literally be cut in
            half.” --Guy
            Nordenson
            Photo: Evangelos Kotsioris




Tuesday, April 17, 12

Responsive design is also inspired by Responsive, or adaptive architecture where buildings
respond and change according to their environment. [read quote] Think of markup, CSS,
JavaScript & media as the structural mass of a website.
Flexible, Fluid Layouts


                        widths, margins, padding in
                        relative units




                  Photo: Sabrina Campagna
                  flickr.com/photos/mar1lyn84/5649648853/


Tuesday, April 17, 12

The foundation of responsive design are layouts in relative units. That means widths, margins
& padding are defined in ems or percents.
Flexible, Fluid Layouts


                                               Target / Context = Result




                        Photo: ansik
                        flickr.com/photos/ansik/304526237/


Tuesday, April 17, 12

This is Ethan Marcotte’s formula for calculating widths in ems. The assumption here is that
most browsers maintain their default setting of a 16px font-size.
Flexible, Fluid Layouts


                                                            24 / 16 = 1.5




                        Photo: ansik
                        flickr.com/photos/ansik/304526237/


Tuesday, April 17, 12

In this example, we’re looking for a 24 pixel font-size. 24/16 is 1.5, so our font size is
1.5em.
Context Changes


                                            13 / 24 = 0.54166666666666




                        Photo: ansik
                        flickr.com/photos/ansik/304526237/


Tuesday, April 17, 12

Beware of context changes. If our font is 1.5em and thus, 24px and we want a 13px font in
that context, we have to divide 13 by 24 (our new context). Notice the number of decimal
points in this example. Marcotte advocates for keeping all those decimal places. I haven’t
been able to find any information as to how many places a different browsers will calculate.
Media Queries




                          Tablet    Netbook                     Desktop
               Sm
                 art
                    p   ho
                          ne




Tuesday, April 17, 12

Back to media queries. After we’ve established our grids, margins and padding in relative
units, media queries are the next important step in making a design responsive.
Media Queries

                        @media screen and (min-width: 480px) {
                            /* CSS goes here */
                        }




Tuesday, April 17, 12

First a browser reads the media type, then evaluates the query. In this case, if the media is
‘screen’ and the browser viewport is at least 480px, the enclosed styles will be rendered.
Media Queries
                            Media


                        @media screen and (min-width: 480px) {
                            /* CSS goes here */
                        }




Tuesday, April 17, 12

First a browser reads the media type, then evaluates the query. In this case, if the media is
‘screen’ and the browser viewport is at least 480px, the enclosed styles will be rendered.
Media Queries
                            Media                               Query


                        @media screen and (min-width: 480px) {
                            /* CSS goes here */
                        }




Tuesday, April 17, 12

First a browser reads the media type, then evaluates the query. In this case, if the media is
‘screen’ and the browser viewport is at least 480px, the enclosed styles will be rendered.
Media Queries

                        @import url(“css/phone.css”) screen
                        and min-width: 480px);




Tuesday, April 17, 12

Here’s an alternate syntax that will load a separate style sheet based on the parameters of
the media query.
Media Queries

                        @import url(“css/phone.css”) screen
                        and min-width: 480px);

                                                                          Media




Tuesday, April 17, 12

Here’s an alternate syntax that will load a separate style sheet based on the parameters of
the media query.
Media Queries

                        @import url(“css/phone.css”) screen
                        and min-width: 480px);

                                           Query                          Media




Tuesday, April 17, 12

Here’s an alternate syntax that will load a separate style sheet based on the parameters of
the media query.
Media Query Options
                        •   width (browser width)

                        •   height (browser height)
                        •   device-width (device-width)
                        •   device-height (device-height)

                        •   orientation (portrait or landscape)
                        •   aspect-ratio (browser aspect ratio)
                        •   device-aspect-ratio (device aspect ratio)
                        •   color (bits of color component of device)

                        •   color-index (number of entries in the color lookup profile)
                        •   monochrome (similar to color but for monochrome devices)
                        •   resolution (pixel-density in DPI)

                        •   scan (TV’s-whether scanning process is progressive or scan)
                        •   grid (grid-based display, like feature phone)




Tuesday, April 17, 12

Here’s a complete list of media query options--including some related to television scanning.
Media Query Options

                        • width (browser width)
                        • height (browser height)
                        • device-width (device-width)
                        • device-height (device-height)
                        • orientation (portrait or landscape)

Tuesday, April 17, 12

In reality these are the most common. I want to point out a few distinctions here. ‘width’ &
‘height’ refer to the browser viewport. ‘device-width’ & ‘device-height’ refer to the height &
width of the device. Device orientation is another handy option.
There are no
                               standard devices!




                             Photo: Oliver White
                             flickr.com/photos/nuage_de_lait/6580839781/

Tuesday, April 17, 12

Until recently, it’s been popular to write queries based on the dimensions of popular devices.
The list on the left of this slide is taken from SUA’s analytics. You can see the incredible
diversity of screen sizes in our mobile analytics. There are no standard devices. Instead of
trying to keep up w/ new device dimensions, you should evaluate the breakpoints of your
design. Look at where the layout gets awkward and set a breakpoint. Then let the devices fall
where they may. New devices appear almost every day. Your design is the constant in the
equation. Plan accordingly.
Set media
                              query
                        breakpoints
                         where the
                              design
                            breaks.

                                    Photo: Ballookey Klugeypop
                         flickr.com/photos/ballookey/136450028/


Tuesday, April 17, 12
“CSS Pixels” &
                             “Hardware Pixels”
                        Apple iPhone 4: 326 ppi                              Sony Ericsson XPERIA X10: 245 ppi

                        LG KM900 Arena: 311 ppi                              Samsung I9000 Galaxy S: 233 ppi

                        Samsung S8000 Jet: 301 ppi                           HTC HD2: 217 ppi

                        Canon EOS 550D (T2i): 289 ppi                        Nokia N8: 210 ppi

                        HTC Touch Diamond: 286 ppi                           Apple iPhone 3GS: 165 ppi

                        Samsung S8500 Wave: 283 ppi                          Apple iPad: 132 ppi

                        HTC Desire: 252 ppi

                        Google Nexus One: 252 ppi
                        Source: blog.gsmarena.com/how-does-the-iphone-4-pixel-density-stand-in-comparison/




Tuesday, April 17, 12

Here are points per inch for several mobile devices. Notice the iPhone 4 at the top with the
most points per inch.
Some Pixels Are More
                         Equal Than Others



                        Hardware Pixel                            CSS Pixel




Tuesday, April 17, 12

The iPhone 4 has a pixel-density of 2. That means there are 2 “hardware” pixels on the screen for every “CSS
pixel.” That makes fonts and images render very crisply on the screen, but it’s a problem when we’re trying to
calculate CSS. Thus we level the field by setting the zoom-level to 100%. When the zoom level is 100%, the ratio of
hardware pixels to CSS is 1.
Some Pixels Are More
                         Equal Than Others



                        Hardware Pixel                CSS Pixel




Tuesday, April 17, 12

By putting “initial-scale=1” in the viewport meta tag forces the browser to make hardware
pixels equal CSS pixels. The problem is, this will apply to text and layout, but images will
zoom up and appear pixelated. You need to figure out the pixel density so the image quality
matches the density of the screen. Which leads us to...
Take Control of The
                               Screen

                        <meta name="viewport"
                        content="width=device-width, initial-
                        scale=1, maximum-scale=1">




Tuesday, April 17, 12

It’s a good idea to use a “viewport” meta tag in the head of your document to gain some
control and provide better consistency between mobile devices.
Take Control of The
                               Screen

                        width=device-width
                        Without this, mobile browsers will zoom the
                        page out to 980px.




Tuesday, April 17, 12

First in that meta tag, I’m telling the browser to make the content width the device width.
device-width
Take Control of The
                               Screen

                        initial-scale = 1
                        Controls the zoom level when the page is
                        loaded. (1 = 100%)




Tuesday, April 17, 12
Take Control of the
                               Screen

                        maximum-scale = 1
                        Controls zooming. In my example, the
                        maximum scale is set to 100%. Other
                        options: minimum-scale & user-scalable.




Tuesday, April 17, 12
Take Control of the
                              Screen




Tuesday, April 17, 12

Left: before setting the viewport meta tag. Right: after.
Responsive Images &
                              Media




  Photo:Vicky Somma
  flickr.com/photos/tgaw/2556511663/
Tuesday, April 17, 12

After after fluid layouts and media queries come responsive images. The talking phones are
outraged that we’re trying to send them a gigantic image.
Responsive Images &
                              Media

                        #container img {
                            max-width: 100%;
                        }


Tuesday, April 17, 12

At their simplest, responsive images respond to the layout by never exceed the width of their
container. Unfortunately HTML alone is lacking in terms of providing a way to place the
smallest possible image on the page. Remember, mobile devices are often lacking in
bandwidth. Sending a large image to a small screen is an unnecessary burden. JavaScript
does provide some relief.
Start with Basic HTML


                         <a id=”home-link” href=”http://sua.umn.edu”>Home</a>




Tuesday, April 17, 12

Start with the lowest common denominator. In this example, I’m using a link, but this could
be any container. This HTML will work with any feature phone.
Use JavaScript to Detect
                     Screen Dimensions


                        h = screen.height;




Tuesday, April 17, 12

Next we have to try to evaluate the screen height. I use height because smart phones could
be turned to landscape mode at any time, making the height the new width.
Use JavaScript to Detect
                     Screen Dimensions
                        h = screen.height;


                        // Pixel ratio (WebKit Only)
                        r = window.devicePixelRatio;



Tuesday, April 17, 12

With the advent of high density screens, we have to account for pixel-density. The iPhone 4
has a pixel density of 2 and many Android phones have a pixel density of 1.5. Depending on
meta tags in the head of your document, an iPhone might report dimensions of 320x480
even though it’s true resolution is 640x960. Caution: devicePixelRatio is WebKit-only.
Fortunately this scenario if pure enhancement and won’t affect the functionality or
information on the page. A non-WebKit browser will simply report a lower resolution and so
the image may seem a little pixelated.
Use JavaScript to Detect
                     Screen Dimensions
                        /* if devicePixelRatio is supported,
                        calculate the device height */
                        if (typeof r !== 'undefined')
                        {
                           /* Calculate the true number of pixels on
                        the screen */
                            height = h * r;
                        }




Tuesday, April 17, 12

We can test for this by making sure the result of devicePixelRatio is not ‘undefined’. If it is,
we simply use the original height reading. If not, we can get the true height by multiplying
the reported height by the pixel-density.
Use JavaScript to Detect
                     Screen Dimensions
                        // Set the image directory accordingly
                        if (height <= 320)
                        {
                            // load 320 header
                            d = 320;
                        }




Tuesday, April 17, 12

In this example, I have directories with names matching a few key heights. A copy of the
image is stored in each directory that matches it’s width. So a 320px wide image resides in
the 320 directory.
Use JavaScript to Detect
                     Screen Dimensions

                        $('a#home-link').html('<img
                        src="/images/mobile/' + d + '/
                        header.png" alt="This is alt
                        text." id="logo"
                        class="logos" />');



Tuesday, April 17, 12

I can then use JQuery write in this HTML with the directory I want. The image will then load
that is large enough for the device, but somewhat optimized for the dimensions of the
screen. This method is not perfect. For instance, the image will not load until after the DOM
has fully loaded--since I’m using JQuery and the ready() method. Still it’s a fairly good
compromise to minimize the bandwidth necessary to load the page.
Mobile First, Mobile
                         Separate & RESS



Tuesday, April 17, 12

Now that I’ve touched on a few techniques, I want to go over three approaches to developing
for mobile. Those are Mobile First, a separate mobile experience and RESS which stands for
Responsive and Server Side.
Mobile First
                  Luke Wroblewski




                  Photo: foltzwerk
                  flickr.com/photos/foltzwerk/2779814860/

Tuesday, April 17, 12

Mobile First is a concept advocated by Luke Wroblewski in his book of the same name. The
basic approach is that sites should be first designed for mobile with desktop versions coming
after. This approach begins with a number of constraints that filter through to the desktop
experience.
Mobile First

                        • One site for all devices
                        • Focus on content that’s truly important
                        • No User Agent sniffing


Tuesday, April 17, 12

Some of the advantage of this approach are that you have one site for all devices. The
constraints force you focus on what’s truly important. You avoid User Agent sniffing that
some other techniques rely upon.
Mobile First

                        • Potential for unnecessary overhead
                        • Convincing stakeholders to embrace
                          constraints may be a barrier
                        • Requires polyfills for older browsers


Tuesday, April 17, 12

Some disadvantages: Mobile networks are often slower, and sometimes users will have a cap
on their data plan. You have to be careful to truly embrace the constraints through the entire
stack so you can minimize the size of pages and media. Along with that, it’s not always easy
to convince stakeholders to embrace those constraints. Finally, for the site to work in all
browsers, you’re going to need to use a few JavaScript polyfills.
Polyfills
                                 Respond: github.com/scottjehl/Respond
                                                       (media queries)
                        Overthrow: github.com/filamentgroup/Overthrow
                                                       (overflow: auto)
                                 html5shiv: code.google.com/p/html5shiv
                                                              (HTML5)




Tuesday, April 17, 12

Respond for media queries in older versions of IE
Overthrow for using overflow: auto
html5shiv if you’re using html5
Feature Detection
                                                 Modernizr modernizr.com




                  Photo: Patrick Ciebilski
                  flickr.com/photos/mccieb/

Tuesday, April 17, 12

Modernizr is a JavaScript library for detecting browser features. It offers a lot of flexibility in
that you can enhance your site based on the capabilities of each browser.
Modernizr
                        •   @font-face               •   CSS reflections
                                                                               •   localStorage
                        •   background-size          •   CSS 2D transforms
                                                                               •   Cross-window
                        •   border-image             •   CSS 3D transforms         messaging

                        •   border-radius            •   CSS transitions       •   sessionStorage

                        •   box-shadow               •   applicationCache      •   Web Sockets

                        •   Flexible Box Model       •   Canvas                •   Web SQL DB

                        •   hsla & rgba color        •   Canvas text           •   Web Workers

                        •   Multiple backgrounds     •   Drag and drop         •   Geolocation

                        •   opacity                  •   haschange Event       •   Inline SVG

                        •   text-shadow              •   History management    •   SMIL

                        •   CSS Animations           •   HTML5 audio & video   •   SVG

                        •   CSS Columns              •   IndexedDB             •   SVG clip pathes

                        •   CSS generated content    •   Input attributes      •   Touch events

                        •   CSS gradients            •   Input types           •   WebGL




Tuesday, April 17, 12

Modernizr has a long list of features that it detects.
Mobile First

                                           Responsive
                                             Images



                                         Media Queries




                                      Flexible, Fluid Layout




Tuesday, April 17, 12

Encompasses all aspects of a responsive design to deliver one site that works for all devices.
Mobile First
                                            Responsive
                                              Images




                                          Media Queries




                                       Flexible, Fluid Layout




                                          Web Standards




Tuesday, April 17, 12

And responsive design is built upon web standards. If you’re already used to developing with
standards, responsive design is just reaching a little further with the same concept.
Tuesday, April 17, 12

Here’s an example of a responsive design in action. Notice how he’s designed the layout and
images to work across different screen widths.
Separate Mobile
                        Experience




Tuesday, April 17, 12

Remember these guys? Both have also done sites with a totally separate mobile experience.
Separate Mobile
                                Experience
                        • Site tailored to use case
                        • Eliminate unnecessary markup, CSS &
                          JavaScript
                        • May be easier to convince stakeholders to
                          embrace constraints



Tuesday, April 17, 12

Some of the advantages of providing a separate mobile experience: The site can be tailored
the use case. You have a lot of control over reducing unnecessary markup, CSS & JavaScript. It
may be easier to convince stakeholders to embrace constraints if they get to keep there
content somewhere else.
Separate Mobile
                                Experience

                        • Two sites
                        • Might not meet all users’ needs
                        • Relies on device detection



Tuesday, April 17, 12

Some of the disadvantages: You maintain two sites. A separate experience might not meet all
your users’ needs. You’re going to have to rely on some sort of device detection.
Device Detection
                             detectmobilebrowsers.com
                                  detector.dmolsen.com




                                                                            Photo: Brad Buchanan
                                                          flickr.com/photos/frozenisles/3443607776/


Tuesday, April 17, 12

For the projects we’ve done at SUA so far, we’ve relied on the script at
detectmobilebrowsers.com. I have more recently come accross Detector and it looks quite
promising.
detectmobilebrowsers.com
                                            Apache          Lasso
                                            ASP             nginx
                                            ASP.NET         node.js
                                            ColdFusion      PHP
                                            C#              Perl
                                            IIS             Python
                                            JSP             Rails
                                            JavaScript
                                            jQuery
                                                                            Photo: Herr Olsen
                                                         flickr.com/photos/herrolsen/6199045384/

Tuesday, April 17, 12

Returns boolean. Available is several languages.
detectmobilebrowsers.com


                        <?php
                        is_mobile();
                        ?>


                   Photo: Jeff Kubina
                   flickr.com/photos/kubina/170938326/

Tuesday, April 17, 12

Using the script is very simple.
Detector

                        • detector.dmolsen.com
                        • PHP only
                        • Beta
                        • Uses same database of tests as
                          Modernizr

                   Photo: Jason Ahrns
                   flickr.com/photos/musubk/5578348098/

Tuesday, April 17, 12

Detector, by comparison, is only available in PHP. It’s still in beta. It does a lot more than
detect whether a device is mobile or not. It also has the same database of feature detection
as Modernizr.
Detector
                        <?php
                        if ($ua->isMobile)
                        {
                              // Code goes here
                         }
                        ?>
                   Photo: DigiTaL~NomAd
                   flickr.com/photos/urban-spaceman/3947680057/

Tuesday, April 17, 12

Here’s an example of how you might use Detector to detect mobile devices.
Preserve
                    The URI
                    When
                    Redirecting                         Photo: Chris Campbell
                                                        flickr.com/photos/cgc/3809196941/



Tuesday, April 17, 12

If you’re using a method to detect and redirect mobile devices, remember to preserve the
URL. That is, if they’re trying to get to a specific page or resource, make sure you redirect
them to the equivalent page or resource on the mobile site. If you don’t have a mobile
version, you shouldn’t be redirecting.
if (is_mobile() && !isset($_COOKIE['mobile']))
              {
                  $redirect = '/mobile/';
                  if (preg_match('/event/(d+)/',
              $_SERVER['REQUEST_URI'], $matches) > 0)
                  {
                      $redirect .= $matches[0];
                  }
                  setcookie('mobile');
                  header('Location: ' . $redirect);
                  exit;
              }




Tuesday, April 17, 12
JQuery Mobile




Tuesday, April 17, 12

We’ve used the JQuery Mobile framework for all of your mobile projects so far.
JQuery Mobile




Tuesday, April 17, 12

For one reason: it’s thoroughly tested. This is an image of the JQuery Mobile testing table of
devices.
JQuery Mobile Setup
                        <div data-role="page">
                           <div data-role="header">
                               <h1>Page Title</h1>
                           </div><!-- /header -->
                           <div data-role="content">
                               <p>Page content goes here.</p>
                           </div><!-- /content -->
                           <div data-role="footer">
                               <h4>Page Footer</h4>
                           </div><!-- /footer -->
                        </div><!-- /page -->




Tuesday, April 17, 12

Setting up the framework is fairly simple. First, it does a require an HTML5 doctype. After
that, it makes extensive use of the HTML5 data attribute. You ca see several “roles” defined in
the markup here.
Ajax Page Loads


              <a itemprop="url" data-transition="slide" href="/path/">link</a>




Tuesday, April 17, 12

The framework also does a lot of heavy lifting for you. For instance, HTML page links are
automagically turned into AJAX page loads with nice transitions defined in a “data-transition”
attribute.
Ajax Page Loads


              <a itemprop="url" data-transition="slide" href="/path/">link</a>




Tuesday, April 17, 12

The framework also does a lot of heavy lifting for you. For instance, HTML page links are
automagically turned into AJAX page loads with nice transitions defined in a “data-transition”
attribute.
JQuery Mobile Page
                         Transition Options
                          • fade                  • slideup
                          • pop                   • slidedown
                          • flip                   • none
                          • turn
                          • flow
                          • slide

Tuesday, April 17, 12

The framework also offers several transition options.
JQuery Mobile Themes




Tuesday, April 17, 12

There are also 6 built-in themes available. You also have the option of designing and coding
styles for your own theme.
JQuery Mobile Themes


                        <div data-theme="a"></div>




Tuesday, April 17, 12

Themes are defined using a “data-theme” attribute.
JQuery Mobile Grid
                            Framework
                        <div class="ui-grid-a">
                          <div class="ui-block-a">
                           </div>
                          <div class="ui-block-b">
                           </div>
                         </div><!-- /grid-a -->




Tuesday, April 17, 12

There is also a grid framework available. Here’s an example of a two-column grid. There’s a
wrapper with the class “ui-grid-a”. The child elements have classes of “ui-block-a” and “ui-
block-b” respectively to place them as two columns on the page.
JQuery Mobile Grid
                             Framework
                        • two-column: ui-grid-a
                        • three-column: ui-grid-b
                        • four-column: ui-grid-c
                        • five-column: ui-grid-d
                                                    Photo: Mike Smail
                                                    flickr.com/photos/smailtronic/2214772479/



Tuesday, April 17, 12

You can create grids all the way up to 5 columns.
Binding JavaScript Events
                      in JQuery Mobile


                        Use pageInit() instead of
                        $(document).ready()




Tuesday, April 17, 12

Since AJAX is used to load page content, $(document).ready() is only called with the first page
load. To successfully trigger events when pages load, use JQuery Mobile’s pageInit instead.
REsponsive & Server
                           Side (RESS)




                  Photo: foltzwerk
                  flickr.com/photos/foltzwerk/2779814860/

Tuesday, April 17, 12

Luke Wroblewski, who authored Mobile First, also has written about RESS, which is a
combination of responsive design techniques and server-side feature detection.
REsponsive & Server
                           Side (RESS)

                        • Heavy lifting handled on server side
                        • Able to provide a finely-tuned experience
                        • Removes need for redirects


Tuesday, April 17, 12

Some of RESS’ advantages: The work of feature detection is handled on the server side,
making the browser on the phone do less work. It offers a way to create a very finely-tuned
experience. No more redirects to a different mobile site. Preserves what Phil Hawksworth calls
the contract of the URI for providing content.
REsponsive & Server
                           Side (RESS)

                        • Harder to execute
                        • Requires some user agent sniffing


Tuesday, April 17, 12
  •    Harder to execute
        ◦ more resources needed in terms of client and server side coding skills and time
        ◦ A lot of thought and planning needs to go into components and device classes (phone, tablet, desktop, TV, etc.)
  •    Requires some user agent sniffing
There is no single
                 solution and I will stand
                 on Jeffery Zeldman’s
                 coffee table and say
                 that.

Tuesday, April 17, 12
Tools & Resources
                        Testing                                Links
                 •      Comprehensive list of emulators:   •   MobilePerf (z.umn.edu/mobileperf)
                        mobilexweb.com/emulators
                                                           •   Adobe Shadow (labs.adobe.com/
                 •      springbox.com/mobilizer                technologies/shadow)

                        Books                              •   lukew.com (@lukew)

                 •      Responsive Web Design - Ethan      •   ethanmarcotte.com (@beep)
                        Marcotte                           •   jquerymobile.com
                 •      Mobile First - Luke Wroblewski     •   detectmobilebrowsers.com
                                                           •   detector.dmolsen.com
                                                           •   mobilizr.com




Tuesday, April 17, 12

Contenu connexe

Similaire à Mobile Web Development: The Challenges & How to Meet Them

Introduction To App-Splash
Introduction To App-SplashIntroduction To App-Splash
Introduction To App-SplashOmar LDeeb
 
General Assembly Sydney: Digital Frontiers Workshop
General Assembly Sydney: Digital Frontiers WorkshopGeneral Assembly Sydney: Digital Frontiers Workshop
General Assembly Sydney: Digital Frontiers WorkshopAlex Young
 
Introduction to Android by Demian Neidetcher
Introduction to Android by Demian NeidetcherIntroduction to Android by Demian Neidetcher
Introduction to Android by Demian NeidetcherMatthew McCullough
 
Dispelling the myths about hotel mobile apps
Dispelling the myths about hotel mobile appsDispelling the myths about hotel mobile apps
Dispelling the myths about hotel mobile appsMobile Media Applications
 
Flurry Analytics - NOAH12 London
Flurry Analytics - NOAH12 LondonFlurry Analytics - NOAH12 London
Flurry Analytics - NOAH12 LondonMarco Rodzynek
 
Flurry Analytics - NOAH12 London
Flurry Analytics - NOAH12 LondonFlurry Analytics - NOAH12 London
Flurry Analytics - NOAH12 LondonNOAH Advisors
 
Mobile Apps - The Business & Technology
Mobile Apps - The Business & TechnologyMobile Apps - The Business & Technology
Mobile Apps - The Business & TechnologyAndri Yadi
 
Hot house istrategy_presentation_february_2012_original-1
Hot house istrategy_presentation_february_2012_original-1Hot house istrategy_presentation_february_2012_original-1
Hot house istrategy_presentation_february_2012_original-1iStrategy
 
HTW2011: Thai Tran - Android: Opportunities and challenges
HTW2011: Thai Tran - Android: Opportunities and challengesHTW2011: Thai Tran - Android: Opportunities and challenges
HTW2011: Thai Tran - Android: Opportunities and challengesHow to Web
 
SoLoMo University by Mobilosoft - Conference 1 - 23/11/2012
SoLoMo University by Mobilosoft - Conference 1 - 23/11/2012SoLoMo University by Mobilosoft - Conference 1 - 23/11/2012
SoLoMo University by Mobilosoft - Conference 1 - 23/11/2012Mobilosoft
 
Pick Your Poison – Mobile Web, Native, or Hybrid? - Denver Startup Week - Oct...
Pick Your Poison – Mobile Web, Native, or Hybrid? - Denver Startup Week - Oct...Pick Your Poison – Mobile Web, Native, or Hybrid? - Denver Startup Week - Oct...
Pick Your Poison – Mobile Web, Native, or Hybrid? - Denver Startup Week - Oct...Shane Church
 
Pick Your Poison – Mobile Web, Native or Hybrid?
Pick Your Poison – Mobile Web, Native or Hybrid?Pick Your Poison – Mobile Web, Native or Hybrid?
Pick Your Poison – Mobile Web, Native or Hybrid?Effective
 
The NUI Paradigm Shift
The NUI Paradigm ShiftThe NUI Paradigm Shift
The NUI Paradigm ShiftSam Woodman
 
Android By Manish Seth
Android By Manish SethAndroid By Manish Seth
Android By Manish SethNitin Gupta
 
App vs Web: Jon Marks Customer Day Presentation 2015
App vs Web: Jon Marks Customer Day Presentation 2015App vs Web: Jon Marks Customer Day Presentation 2015
App vs Web: Jon Marks Customer Day Presentation 2015KaldorLtd
 
NRB 2012 ReFrame Mobile Case Study
NRB 2012 ReFrame Mobile Case StudyNRB 2012 ReFrame Mobile Case Study
NRB 2012 ReFrame Mobile Case StudySteven Koster
 
Smartphone Changes World
Smartphone Changes WorldSmartphone Changes World
Smartphone Changes WorldGunhee Lee
 

Similaire à Mobile Web Development: The Challenges & How to Meet Them (20)

Introduction To App-Splash
Introduction To App-SplashIntroduction To App-Splash
Introduction To App-Splash
 
General Assembly Sydney: Digital Frontiers Workshop
General Assembly Sydney: Digital Frontiers WorkshopGeneral Assembly Sydney: Digital Frontiers Workshop
General Assembly Sydney: Digital Frontiers Workshop
 
Introduction to Android by Demian Neidetcher
Introduction to Android by Demian NeidetcherIntroduction to Android by Demian Neidetcher
Introduction to Android by Demian Neidetcher
 
Dispelling the myths about hotel mobile apps
Dispelling the myths about hotel mobile appsDispelling the myths about hotel mobile apps
Dispelling the myths about hotel mobile apps
 
Flurry Analytics - NOAH12 London
Flurry Analytics - NOAH12 LondonFlurry Analytics - NOAH12 London
Flurry Analytics - NOAH12 London
 
Flurry Analytics - NOAH12 London
Flurry Analytics - NOAH12 LondonFlurry Analytics - NOAH12 London
Flurry Analytics - NOAH12 London
 
Mobile Apps - The Business & Technology
Mobile Apps - The Business & TechnologyMobile Apps - The Business & Technology
Mobile Apps - The Business & Technology
 
Hot house istrategy_presentation_february_2012_original-1
Hot house istrategy_presentation_february_2012_original-1Hot house istrategy_presentation_february_2012_original-1
Hot house istrategy_presentation_february_2012_original-1
 
HTW2011: Thai Tran - Android: Opportunities and challenges
HTW2011: Thai Tran - Android: Opportunities and challengesHTW2011: Thai Tran - Android: Opportunities and challenges
HTW2011: Thai Tran - Android: Opportunities and challenges
 
SoLoMo University by Mobilosoft - Conference 1 - 23/11/2012
SoLoMo University by Mobilosoft - Conference 1 - 23/11/2012SoLoMo University by Mobilosoft - Conference 1 - 23/11/2012
SoLoMo University by Mobilosoft - Conference 1 - 23/11/2012
 
Pick Your Poison – Mobile Web, Native, or Hybrid? - Denver Startup Week - Oct...
Pick Your Poison – Mobile Web, Native, or Hybrid? - Denver Startup Week - Oct...Pick Your Poison – Mobile Web, Native, or Hybrid? - Denver Startup Week - Oct...
Pick Your Poison – Mobile Web, Native, or Hybrid? - Denver Startup Week - Oct...
 
Pick Your Poison – Mobile Web, Native or Hybrid?
Pick Your Poison – Mobile Web, Native or Hybrid?Pick Your Poison – Mobile Web, Native or Hybrid?
Pick Your Poison – Mobile Web, Native or Hybrid?
 
The NUI Paradigm Shift
The NUI Paradigm ShiftThe NUI Paradigm Shift
The NUI Paradigm Shift
 
Android By Manish Seth
Android By Manish SethAndroid By Manish Seth
Android By Manish Seth
 
App vs Web: Jon Marks Customer Day Presentation 2015
App vs Web: Jon Marks Customer Day Presentation 2015App vs Web: Jon Marks Customer Day Presentation 2015
App vs Web: Jon Marks Customer Day Presentation 2015
 
NRB 2012 ReFrame Mobile Case Study
NRB 2012 ReFrame Mobile Case StudyNRB 2012 ReFrame Mobile Case Study
NRB 2012 ReFrame Mobile Case Study
 
Workshop digital 7 - Digital communication in practice: mobile media (Wim VER...
Workshop digital 7 - Digital communication in practice: mobile media (Wim VER...Workshop digital 7 - Digital communication in practice: mobile media (Wim VER...
Workshop digital 7 - Digital communication in practice: mobile media (Wim VER...
 
Mobilize UGent
Mobilize UGentMobilize UGent
Mobilize UGent
 
iPhone Apps
iPhone AppsiPhone Apps
iPhone Apps
 
Smartphone Changes World
Smartphone Changes WorldSmartphone Changes World
Smartphone Changes World
 

Dernier

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 

Dernier (20)

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 

Mobile Web Development: The Challenges & How to Meet Them

  • 1. Mobile Web Development The Challenges and How To Meet Them Tony Thomas - Student Unions & Activities at The University of Minnesota Tuesday, April 17, 12
  • 2. Student Unions & Activities 2011 Poll 50% have a smartphone 7% plan to get one Tuesday, April 17, 12 Our unscientific student poll.
  • 3. Tuesday, April 17, 12 Recognize?
  • 4. Yavin Tuesday, April 17, 12 This is Yavin, a red giant planet.
  • 5. Yavin 4 Yavin Tuesday, April 17, 12 This is Yavin 4, the location of the rebel base
  • 6. Student Unions & Activities Website 2011: 4.34% Tuesday, April 17, 12 A snapshot from SUA a year ago.
  • 7. Student Unions & Activities Website 2012: 9.03% Tuesday, April 17, 12 This year.
  • 8. Homecoming Website 2010: 3.8% Tuesday, April 17, 12 Homecoming 2010 during the event.
  • 9. Homecoming Website 2011: 11.64% Tuesday, April 17, 12 Homecoming 2011 during the event.
  • 10. Spring Jam Website 2010: 5.46% Tuesday, April 17, 12 Spring Jam 2011 during the event.
  • 11. Spring Jam Website 2011: 13.44% Tuesday, April 17, 12 Spring Jam 2011 during the event.
  • 12. Mobile Operating Systems 21458 21500 10330 767 82 56 37 31 6 4 0 S d y e S g ia top iO roi err on ianO sun ok LG nd ckb Ph b am N Hip A Bla ows Sym S nge r d W in Da Tuesday, April 17, 12 Our users are predominantly iOS & Android. Blackberry distant 3rd. Long tail of others.
  • 13. Device Dimensions Android Android Samsung Nokia Android Android Android Android Blackberry Android Blackberry Android Windows Android Android Android Android Blackberry Android Android Android Android Android Android Android Android Nokia Android Android iPhone iPod Android Android Blackberry Samsung Blackberry Blackberry SymbianOS SymbianOS Blackberry Tuesday, April 17, 12 This is just a small sample of device dimensions taken from 1 month of SUA mobile traffic.
  • 14. Responsive Design Ethan Marcotte Photo: Peter J. Hart flickr.com/photos/40054618@N03/5140728113/ Tuesday, April 17, 12 This is Ethan Marcotte who introduced the concept of responsive design in 2010.
  • 15. A Dao of Web Design John Allsopp Photo: drewm flickr.com/photos/drewm/ flickr.com/photos/drewm/4732738890/ Tuesday, April 17, 12 It’s in part inspired by John Allsopp’s 2000 A List Apart article called “A Dao of Web Design.”
  • 16. A Dao of Web Design alistapart.com/articles/dao/ “It’s time to throw out the rituals of the printed page, and to engage the medium of the web and its own nature.” Tuesday, April 17, 12 [Read quote.] Back in 2000, Allsopp was advocating for embracing the inherent flexible nature of the web.
  • 17. Responsive Architecture “If a building could change its posture, tighten its muscles and brace itself against the wind, its structural mass could literally be cut in half.” --Guy Nordenson Photo: Evangelos Kotsioris Tuesday, April 17, 12 Responsive design is also inspired by Responsive, or adaptive architecture where buildings respond and change according to their environment. [read quote] Think of markup, CSS, JavaScript & media as the structural mass of a website.
  • 18. Flexible, Fluid Layouts widths, margins, padding in relative units Photo: Sabrina Campagna flickr.com/photos/mar1lyn84/5649648853/ Tuesday, April 17, 12 The foundation of responsive design are layouts in relative units. That means widths, margins & padding are defined in ems or percents.
  • 19. Flexible, Fluid Layouts Target / Context = Result Photo: ansik flickr.com/photos/ansik/304526237/ Tuesday, April 17, 12 This is Ethan Marcotte’s formula for calculating widths in ems. The assumption here is that most browsers maintain their default setting of a 16px font-size.
  • 20. Flexible, Fluid Layouts 24 / 16 = 1.5 Photo: ansik flickr.com/photos/ansik/304526237/ Tuesday, April 17, 12 In this example, we’re looking for a 24 pixel font-size. 24/16 is 1.5, so our font size is 1.5em.
  • 21. Context Changes 13 / 24 = 0.54166666666666 Photo: ansik flickr.com/photos/ansik/304526237/ Tuesday, April 17, 12 Beware of context changes. If our font is 1.5em and thus, 24px and we want a 13px font in that context, we have to divide 13 by 24 (our new context). Notice the number of decimal points in this example. Marcotte advocates for keeping all those decimal places. I haven’t been able to find any information as to how many places a different browsers will calculate.
  • 22. Media Queries Tablet Netbook Desktop Sm art p ho ne Tuesday, April 17, 12 Back to media queries. After we’ve established our grids, margins and padding in relative units, media queries are the next important step in making a design responsive.
  • 23. Media Queries @media screen and (min-width: 480px) { /* CSS goes here */ } Tuesday, April 17, 12 First a browser reads the media type, then evaluates the query. In this case, if the media is ‘screen’ and the browser viewport is at least 480px, the enclosed styles will be rendered.
  • 24. Media Queries Media @media screen and (min-width: 480px) { /* CSS goes here */ } Tuesday, April 17, 12 First a browser reads the media type, then evaluates the query. In this case, if the media is ‘screen’ and the browser viewport is at least 480px, the enclosed styles will be rendered.
  • 25. Media Queries Media Query @media screen and (min-width: 480px) { /* CSS goes here */ } Tuesday, April 17, 12 First a browser reads the media type, then evaluates the query. In this case, if the media is ‘screen’ and the browser viewport is at least 480px, the enclosed styles will be rendered.
  • 26. Media Queries @import url(“css/phone.css”) screen and min-width: 480px); Tuesday, April 17, 12 Here’s an alternate syntax that will load a separate style sheet based on the parameters of the media query.
  • 27. Media Queries @import url(“css/phone.css”) screen and min-width: 480px); Media Tuesday, April 17, 12 Here’s an alternate syntax that will load a separate style sheet based on the parameters of the media query.
  • 28. Media Queries @import url(“css/phone.css”) screen and min-width: 480px); Query Media Tuesday, April 17, 12 Here’s an alternate syntax that will load a separate style sheet based on the parameters of the media query.
  • 29. Media Query Options • width (browser width) • height (browser height) • device-width (device-width) • device-height (device-height) • orientation (portrait or landscape) • aspect-ratio (browser aspect ratio) • device-aspect-ratio (device aspect ratio) • color (bits of color component of device) • color-index (number of entries in the color lookup profile) • monochrome (similar to color but for monochrome devices) • resolution (pixel-density in DPI) • scan (TV’s-whether scanning process is progressive or scan) • grid (grid-based display, like feature phone) Tuesday, April 17, 12 Here’s a complete list of media query options--including some related to television scanning.
  • 30. Media Query Options • width (browser width) • height (browser height) • device-width (device-width) • device-height (device-height) • orientation (portrait or landscape) Tuesday, April 17, 12 In reality these are the most common. I want to point out a few distinctions here. ‘width’ & ‘height’ refer to the browser viewport. ‘device-width’ & ‘device-height’ refer to the height & width of the device. Device orientation is another handy option.
  • 31. There are no standard devices! Photo: Oliver White flickr.com/photos/nuage_de_lait/6580839781/ Tuesday, April 17, 12 Until recently, it’s been popular to write queries based on the dimensions of popular devices. The list on the left of this slide is taken from SUA’s analytics. You can see the incredible diversity of screen sizes in our mobile analytics. There are no standard devices. Instead of trying to keep up w/ new device dimensions, you should evaluate the breakpoints of your design. Look at where the layout gets awkward and set a breakpoint. Then let the devices fall where they may. New devices appear almost every day. Your design is the constant in the equation. Plan accordingly.
  • 32. Set media query breakpoints where the design breaks. Photo: Ballookey Klugeypop flickr.com/photos/ballookey/136450028/ Tuesday, April 17, 12
  • 33. “CSS Pixels” & “Hardware Pixels” Apple iPhone 4: 326 ppi Sony Ericsson XPERIA X10: 245 ppi LG KM900 Arena: 311 ppi Samsung I9000 Galaxy S: 233 ppi Samsung S8000 Jet: 301 ppi HTC HD2: 217 ppi Canon EOS 550D (T2i): 289 ppi Nokia N8: 210 ppi HTC Touch Diamond: 286 ppi Apple iPhone 3GS: 165 ppi Samsung S8500 Wave: 283 ppi Apple iPad: 132 ppi HTC Desire: 252 ppi Google Nexus One: 252 ppi Source: blog.gsmarena.com/how-does-the-iphone-4-pixel-density-stand-in-comparison/ Tuesday, April 17, 12 Here are points per inch for several mobile devices. Notice the iPhone 4 at the top with the most points per inch.
  • 34. Some Pixels Are More Equal Than Others Hardware Pixel CSS Pixel Tuesday, April 17, 12 The iPhone 4 has a pixel-density of 2. That means there are 2 “hardware” pixels on the screen for every “CSS pixel.” That makes fonts and images render very crisply on the screen, but it’s a problem when we’re trying to calculate CSS. Thus we level the field by setting the zoom-level to 100%. When the zoom level is 100%, the ratio of hardware pixels to CSS is 1.
  • 35. Some Pixels Are More Equal Than Others Hardware Pixel CSS Pixel Tuesday, April 17, 12 By putting “initial-scale=1” in the viewport meta tag forces the browser to make hardware pixels equal CSS pixels. The problem is, this will apply to text and layout, but images will zoom up and appear pixelated. You need to figure out the pixel density so the image quality matches the density of the screen. Which leads us to...
  • 36. Take Control of The Screen <meta name="viewport" content="width=device-width, initial- scale=1, maximum-scale=1"> Tuesday, April 17, 12 It’s a good idea to use a “viewport” meta tag in the head of your document to gain some control and provide better consistency between mobile devices.
  • 37. Take Control of The Screen width=device-width Without this, mobile browsers will zoom the page out to 980px. Tuesday, April 17, 12 First in that meta tag, I’m telling the browser to make the content width the device width. device-width
  • 38. Take Control of The Screen initial-scale = 1 Controls the zoom level when the page is loaded. (1 = 100%) Tuesday, April 17, 12
  • 39. Take Control of the Screen maximum-scale = 1 Controls zooming. In my example, the maximum scale is set to 100%. Other options: minimum-scale & user-scalable. Tuesday, April 17, 12
  • 40. Take Control of the Screen Tuesday, April 17, 12 Left: before setting the viewport meta tag. Right: after.
  • 41. Responsive Images & Media Photo:Vicky Somma flickr.com/photos/tgaw/2556511663/ Tuesday, April 17, 12 After after fluid layouts and media queries come responsive images. The talking phones are outraged that we’re trying to send them a gigantic image.
  • 42. Responsive Images & Media #container img { max-width: 100%; } Tuesday, April 17, 12 At their simplest, responsive images respond to the layout by never exceed the width of their container. Unfortunately HTML alone is lacking in terms of providing a way to place the smallest possible image on the page. Remember, mobile devices are often lacking in bandwidth. Sending a large image to a small screen is an unnecessary burden. JavaScript does provide some relief.
  • 43. Start with Basic HTML <a id=”home-link” href=”http://sua.umn.edu”>Home</a> Tuesday, April 17, 12 Start with the lowest common denominator. In this example, I’m using a link, but this could be any container. This HTML will work with any feature phone.
  • 44. Use JavaScript to Detect Screen Dimensions h = screen.height; Tuesday, April 17, 12 Next we have to try to evaluate the screen height. I use height because smart phones could be turned to landscape mode at any time, making the height the new width.
  • 45. Use JavaScript to Detect Screen Dimensions h = screen.height; // Pixel ratio (WebKit Only) r = window.devicePixelRatio; Tuesday, April 17, 12 With the advent of high density screens, we have to account for pixel-density. The iPhone 4 has a pixel density of 2 and many Android phones have a pixel density of 1.5. Depending on meta tags in the head of your document, an iPhone might report dimensions of 320x480 even though it’s true resolution is 640x960. Caution: devicePixelRatio is WebKit-only. Fortunately this scenario if pure enhancement and won’t affect the functionality or information on the page. A non-WebKit browser will simply report a lower resolution and so the image may seem a little pixelated.
  • 46. Use JavaScript to Detect Screen Dimensions /* if devicePixelRatio is supported, calculate the device height */ if (typeof r !== 'undefined') {    /* Calculate the true number of pixels on the screen */     height = h * r; } Tuesday, April 17, 12 We can test for this by making sure the result of devicePixelRatio is not ‘undefined’. If it is, we simply use the original height reading. If not, we can get the true height by multiplying the reported height by the pixel-density.
  • 47. Use JavaScript to Detect Screen Dimensions // Set the image directory accordingly if (height <= 320) {     // load 320 header     d = 320; } Tuesday, April 17, 12 In this example, I have directories with names matching a few key heights. A copy of the image is stored in each directory that matches it’s width. So a 320px wide image resides in the 320 directory.
  • 48. Use JavaScript to Detect Screen Dimensions $('a#home-link').html('<img src="/images/mobile/' + d + '/ header.png" alt="This is alt text." id="logo" class="logos" />'); Tuesday, April 17, 12 I can then use JQuery write in this HTML with the directory I want. The image will then load that is large enough for the device, but somewhat optimized for the dimensions of the screen. This method is not perfect. For instance, the image will not load until after the DOM has fully loaded--since I’m using JQuery and the ready() method. Still it’s a fairly good compromise to minimize the bandwidth necessary to load the page.
  • 49. Mobile First, Mobile Separate & RESS Tuesday, April 17, 12 Now that I’ve touched on a few techniques, I want to go over three approaches to developing for mobile. Those are Mobile First, a separate mobile experience and RESS which stands for Responsive and Server Side.
  • 50. Mobile First Luke Wroblewski Photo: foltzwerk flickr.com/photos/foltzwerk/2779814860/ Tuesday, April 17, 12 Mobile First is a concept advocated by Luke Wroblewski in his book of the same name. The basic approach is that sites should be first designed for mobile with desktop versions coming after. This approach begins with a number of constraints that filter through to the desktop experience.
  • 51. Mobile First • One site for all devices • Focus on content that’s truly important • No User Agent sniffing Tuesday, April 17, 12 Some of the advantage of this approach are that you have one site for all devices. The constraints force you focus on what’s truly important. You avoid User Agent sniffing that some other techniques rely upon.
  • 52. Mobile First • Potential for unnecessary overhead • Convincing stakeholders to embrace constraints may be a barrier • Requires polyfills for older browsers Tuesday, April 17, 12 Some disadvantages: Mobile networks are often slower, and sometimes users will have a cap on their data plan. You have to be careful to truly embrace the constraints through the entire stack so you can minimize the size of pages and media. Along with that, it’s not always easy to convince stakeholders to embrace those constraints. Finally, for the site to work in all browsers, you’re going to need to use a few JavaScript polyfills.
  • 53. Polyfills Respond: github.com/scottjehl/Respond (media queries) Overthrow: github.com/filamentgroup/Overthrow (overflow: auto) html5shiv: code.google.com/p/html5shiv (HTML5) Tuesday, April 17, 12 Respond for media queries in older versions of IE Overthrow for using overflow: auto html5shiv if you’re using html5
  • 54. Feature Detection Modernizr modernizr.com Photo: Patrick Ciebilski flickr.com/photos/mccieb/ Tuesday, April 17, 12 Modernizr is a JavaScript library for detecting browser features. It offers a lot of flexibility in that you can enhance your site based on the capabilities of each browser.
  • 55. Modernizr • @font-face • CSS reflections • localStorage • background-size • CSS 2D transforms • Cross-window • border-image • CSS 3D transforms messaging • border-radius • CSS transitions • sessionStorage • box-shadow • applicationCache • Web Sockets • Flexible Box Model • Canvas • Web SQL DB • hsla & rgba color • Canvas text • Web Workers • Multiple backgrounds • Drag and drop • Geolocation • opacity • haschange Event • Inline SVG • text-shadow • History management • SMIL • CSS Animations • HTML5 audio & video • SVG • CSS Columns • IndexedDB • SVG clip pathes • CSS generated content • Input attributes • Touch events • CSS gradients • Input types • WebGL Tuesday, April 17, 12 Modernizr has a long list of features that it detects.
  • 56. Mobile First Responsive Images Media Queries Flexible, Fluid Layout Tuesday, April 17, 12 Encompasses all aspects of a responsive design to deliver one site that works for all devices.
  • 57. Mobile First Responsive Images Media Queries Flexible, Fluid Layout Web Standards Tuesday, April 17, 12 And responsive design is built upon web standards. If you’re already used to developing with standards, responsive design is just reaching a little further with the same concept.
  • 58. Tuesday, April 17, 12 Here’s an example of a responsive design in action. Notice how he’s designed the layout and images to work across different screen widths.
  • 59. Separate Mobile Experience Tuesday, April 17, 12 Remember these guys? Both have also done sites with a totally separate mobile experience.
  • 60. Separate Mobile Experience • Site tailored to use case • Eliminate unnecessary markup, CSS & JavaScript • May be easier to convince stakeholders to embrace constraints Tuesday, April 17, 12 Some of the advantages of providing a separate mobile experience: The site can be tailored the use case. You have a lot of control over reducing unnecessary markup, CSS & JavaScript. It may be easier to convince stakeholders to embrace constraints if they get to keep there content somewhere else.
  • 61. Separate Mobile Experience • Two sites • Might not meet all users’ needs • Relies on device detection Tuesday, April 17, 12 Some of the disadvantages: You maintain two sites. A separate experience might not meet all your users’ needs. You’re going to have to rely on some sort of device detection.
  • 62. Device Detection detectmobilebrowsers.com detector.dmolsen.com Photo: Brad Buchanan flickr.com/photos/frozenisles/3443607776/ Tuesday, April 17, 12 For the projects we’ve done at SUA so far, we’ve relied on the script at detectmobilebrowsers.com. I have more recently come accross Detector and it looks quite promising.
  • 63. detectmobilebrowsers.com Apache Lasso ASP nginx ASP.NET node.js ColdFusion PHP C# Perl IIS Python JSP Rails JavaScript jQuery Photo: Herr Olsen flickr.com/photos/herrolsen/6199045384/ Tuesday, April 17, 12 Returns boolean. Available is several languages.
  • 64. detectmobilebrowsers.com <?php is_mobile(); ?> Photo: Jeff Kubina flickr.com/photos/kubina/170938326/ Tuesday, April 17, 12 Using the script is very simple.
  • 65. Detector • detector.dmolsen.com • PHP only • Beta • Uses same database of tests as Modernizr Photo: Jason Ahrns flickr.com/photos/musubk/5578348098/ Tuesday, April 17, 12 Detector, by comparison, is only available in PHP. It’s still in beta. It does a lot more than detect whether a device is mobile or not. It also has the same database of feature detection as Modernizr.
  • 66. Detector <?php if ($ua->isMobile) { // Code goes here } ?> Photo: DigiTaL~NomAd flickr.com/photos/urban-spaceman/3947680057/ Tuesday, April 17, 12 Here’s an example of how you might use Detector to detect mobile devices.
  • 67. Preserve The URI When Redirecting Photo: Chris Campbell flickr.com/photos/cgc/3809196941/ Tuesday, April 17, 12 If you’re using a method to detect and redirect mobile devices, remember to preserve the URL. That is, if they’re trying to get to a specific page or resource, make sure you redirect them to the equivalent page or resource on the mobile site. If you don’t have a mobile version, you shouldn’t be redirecting.
  • 68. if (is_mobile() && !isset($_COOKIE['mobile'])) { $redirect = '/mobile/'; if (preg_match('/event/(d+)/', $_SERVER['REQUEST_URI'], $matches) > 0) { $redirect .= $matches[0]; } setcookie('mobile'); header('Location: ' . $redirect); exit; } Tuesday, April 17, 12
  • 69. JQuery Mobile Tuesday, April 17, 12 We’ve used the JQuery Mobile framework for all of your mobile projects so far.
  • 70. JQuery Mobile Tuesday, April 17, 12 For one reason: it’s thoroughly tested. This is an image of the JQuery Mobile testing table of devices.
  • 71. JQuery Mobile Setup <div data-role="page"> <div data-role="header"> <h1>Page Title</h1> </div><!-- /header --> <div data-role="content"> <p>Page content goes here.</p> </div><!-- /content --> <div data-role="footer"> <h4>Page Footer</h4> </div><!-- /footer --> </div><!-- /page --> Tuesday, April 17, 12 Setting up the framework is fairly simple. First, it does a require an HTML5 doctype. After that, it makes extensive use of the HTML5 data attribute. You ca see several “roles” defined in the markup here.
  • 72. Ajax Page Loads <a itemprop="url" data-transition="slide" href="/path/">link</a> Tuesday, April 17, 12 The framework also does a lot of heavy lifting for you. For instance, HTML page links are automagically turned into AJAX page loads with nice transitions defined in a “data-transition” attribute.
  • 73. Ajax Page Loads <a itemprop="url" data-transition="slide" href="/path/">link</a> Tuesday, April 17, 12 The framework also does a lot of heavy lifting for you. For instance, HTML page links are automagically turned into AJAX page loads with nice transitions defined in a “data-transition” attribute.
  • 74. JQuery Mobile Page Transition Options • fade • slideup • pop • slidedown • flip • none • turn • flow • slide Tuesday, April 17, 12 The framework also offers several transition options.
  • 75. JQuery Mobile Themes Tuesday, April 17, 12 There are also 6 built-in themes available. You also have the option of designing and coding styles for your own theme.
  • 76. JQuery Mobile Themes <div data-theme="a"></div> Tuesday, April 17, 12 Themes are defined using a “data-theme” attribute.
  • 77. JQuery Mobile Grid Framework <div class="ui-grid-a"> <div class="ui-block-a"> </div> <div class="ui-block-b"> </div> </div><!-- /grid-a --> Tuesday, April 17, 12 There is also a grid framework available. Here’s an example of a two-column grid. There’s a wrapper with the class “ui-grid-a”. The child elements have classes of “ui-block-a” and “ui- block-b” respectively to place them as two columns on the page.
  • 78. JQuery Mobile Grid Framework • two-column: ui-grid-a • three-column: ui-grid-b • four-column: ui-grid-c • five-column: ui-grid-d Photo: Mike Smail flickr.com/photos/smailtronic/2214772479/ Tuesday, April 17, 12 You can create grids all the way up to 5 columns.
  • 79. Binding JavaScript Events in JQuery Mobile Use pageInit() instead of $(document).ready() Tuesday, April 17, 12 Since AJAX is used to load page content, $(document).ready() is only called with the first page load. To successfully trigger events when pages load, use JQuery Mobile’s pageInit instead.
  • 80. REsponsive & Server Side (RESS) Photo: foltzwerk flickr.com/photos/foltzwerk/2779814860/ Tuesday, April 17, 12 Luke Wroblewski, who authored Mobile First, also has written about RESS, which is a combination of responsive design techniques and server-side feature detection.
  • 81. REsponsive & Server Side (RESS) • Heavy lifting handled on server side • Able to provide a finely-tuned experience • Removes need for redirects Tuesday, April 17, 12 Some of RESS’ advantages: The work of feature detection is handled on the server side, making the browser on the phone do less work. It offers a way to create a very finely-tuned experience. No more redirects to a different mobile site. Preserves what Phil Hawksworth calls the contract of the URI for providing content.
  • 82. REsponsive & Server Side (RESS) • Harder to execute • Requires some user agent sniffing Tuesday, April 17, 12 • Harder to execute ◦ more resources needed in terms of client and server side coding skills and time ◦ A lot of thought and planning needs to go into components and device classes (phone, tablet, desktop, TV, etc.) • Requires some user agent sniffing
  • 83. There is no single solution and I will stand on Jeffery Zeldman’s coffee table and say that. Tuesday, April 17, 12
  • 84. Tools & Resources Testing Links • Comprehensive list of emulators: • MobilePerf (z.umn.edu/mobileperf) mobilexweb.com/emulators • Adobe Shadow (labs.adobe.com/ • springbox.com/mobilizer technologies/shadow) Books • lukew.com (@lukew) • Responsive Web Design - Ethan • ethanmarcotte.com (@beep) Marcotte • jquerymobile.com • Mobile First - Luke Wroblewski • detectmobilebrowsers.com • detector.dmolsen.com • mobilizr.com Tuesday, April 17, 12