Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Going Mobile First With Drupal

Going Mobile First With Drupal

Building Drupal sites mobile first with lazy loading, responsive media and Varnish - without driving anyone insane. A combined session, technical overview, and outlined solution.

Jesper Wøldiche

April 28, 2012
Tweet

More Decks by Jesper Wøldiche

Other Decks in Technology

Transcript

  1. Jesper Wøldiche Rahkonen Municipality of Aarhus designer / markup marine

    / project lead / woeldiche on twitter / quora / linkedin / etc. About me
  2. Overview 0: RWD 1: Mobile First 2: Challenges 3: Requirements

    4: Solution A quick peak at RWD What and why mobile first?. Lazy loading, images, resources. Requirements for a solution. Outline of a Drupal solution.
  3. Mobile first in a responsive web design context. Mobile first

    does not necessitate responsive web design. This workshop
  4. Mobile first in a responsive web design context. Mobile first

    does not necessitate responsive web design. Alternatives later. This workshop
  5. One article = one url. Update content once. Maintain one

    platform only. RWD solves challenges.
  6. SD

  7. “Designing for mobile first not only prepares you for the

    explosive growth and new opportunities on the mobile internet, it forces you to focus and enables you to innovate in ways you previously couldn’t.” - Luke Wroblewski
  8. Design/build a desktop version Port things to mobile - maybe.

    Or ‘responsive’. Hide content - after loading it. The traditional way
  9. Design mobile version first. Even if you are not planning

    on doing a mobile. A development process
  10. Design mobile version first. Even if you are not planning

    on doing a mobile. Build and build on top of mobile. A development process
  11. Design mobile version first. Even if you are not planning

    on doing a mobile. Build and build on top of mobile. Add & adapt content going up. A development process
  12. SD

  13. SD

  14. ‘Performance test of 347 responsive web sites (in 2012!) reveals

    absolute train wreck of mobile-last, display:none “strategies”.’ - Stephanie Rieger
  15. ‘Only 3% of responsive sites had a much smaller performance

    footprint on small screens than on large screens #bdconf’ - Brad Frost, @bradfrost
  16. The performant mobile site Smaller images, lower bandwidth media Fewer

    graphics Progressive loading of JS and resources.
  17. The performant mobile site Smaller images, lower bandwidth media Fewer

    graphics Progressive loading of JS and resources. Less content up front (progressive disclosure)
  18. The performant mobile site Smaller images, lower bandwidth media Fewer

    graphics Progressive loading of JS and resources. Less content up front (progressive disclosure) Sensible defaults
  19. Lazy, asynchronous loading of content and resources. Adaptive images and

    media. Modular, progressive loading of resources. Two (three) issues
  20. Load regions based on mediaquery. Cacheable for anymous users. Attempt

    reduce number of bootstraps Serve core content as HTML Configurable Reusable Each region targetable with URL. Requirements for solution
  21. An extendable contrib module. One admin page. Rewrites page output.

    Sends JSON output based on URL parameters.
  22. Define named presets for layouts (eg. ‘narrow’, ‘normal’, ‘mobile’). Select

    core region(s). Output as HTML. Configuration component.
  23. Define named presets for layouts (eg. ‘narrow’, ‘normal’, ‘mobile’). Select

    core region(s). Output as HTML. Select additional, js-loaded regions for each preset. Configuration component.
  24. Define named presets for layouts (eg. ‘narrow’, ‘normal’, ‘mobile’). Select

    core region(s). Output as HTML. Select additional, js-loaded regions for each preset. Define media queries for each preset (width, height for starters). Configuration component.
  25. page.tpl.php includes <?php print $region; ?> for all regions as

    normal. Conditionally set [‘#access’] = FALSE; for optional regions based on query-string in URL in hook_page_alter(). Template component
  26. page.tpl.php includes <?php print $region; ?> for all regions as

    normal. Conditionally set [‘#access’] = FALSE; for optional regions based on query-string in URL in hook_page_alter(). Output optionally include a link to full version. Template component
  27. SD

  28. Adds an admin page (see above). Returns optional regions as

    JSON in 1 request. Server-side component
  29. Adds an admin page (see above). Returns optional regions as

    JSON in 1 request. Based on appended “responsive=true” & preset (eg. preset=narrow). Server-side component
  30. Adds an admin page (see above). Returns optional regions as

    JSON in 1 request. Based on appended “responsive=true” & preset (eg. preset=narrow). Or renders optional regions as HTML on ‘responsive=false&preset=desktop’ (for testing). Server-side component
  31. Module grab all required regions, return as a json array

    using drupal_json_output() Server-side component 2
  32. Module grab all required regions, return as a json array

    using drupal_json_output() Include information about target (#siderbar-right) to JSON. Server-side component 2
  33. Module grab all required regions, return as a json array

    using drupal_json_output() Include information about target (#siderbar-right) to JSON. Return page with all regions using query Server-side component 2
  34. SD

  35. Client-side JS loaded on page-load. First page load includes lists

    of presets and mediaqueries in drupal.settings. Client-side component
  36. Client-side JS loaded on page-load. First page load includes lists

    of presets and mediaqueries in drupal.settings. JS requests additional content and includes relevant preset and URL. Client-side component
  37. Client-side JS loaded on page-load. First page load includes lists

    of presets and mediaqueries in drupal.settings. JS requests additional content and includes relevant preset and URL. Server sends additional regions as JSON - including information on targets. Client-side component
  38. Client-side JS loaded on page-load. First page load includes lists

    of presets and mediaqueries in drupal.settings. JS requests additional content and includes relevant preset and URL. Server sends additional regions as JSON - including information on targets. JS inserts region content from JSON into DOM. Client-side component
  39. ‘Responsive Webdesign’, Ethan Marcotte. ‘Mobile First’, Luke Wroblewski. ‘A New

    Canon’, Mark Boulton. ‘Reponsible Responsive Images’, Jeremy Keith. ‘Responsive IMGs’, Jason Grigsby. Links online. More sources