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

Responsibly Responsive JavaScript

Responsibly Responsive JavaScript

How you can use JavaScript to help (not hinder) your shiny new responsive websites.

Avatar for Mark Perkins

Mark Perkins

October 11, 2012
Tweet

More Decks by Mark Perkins

Other Decks in Technology

Transcript

  1. Responsibly Responsive JavaScript How you can use JavaScript to help

    (not hinder) your shiny new Responsive™ websites Mark Perkins 11th October, 2012
  2. We need to think about JS a li le differently

    now. Don’t assume what worked before is still best practice. Reevaluate, reconsider, rework.
  3. • Take time to reconsider the way you currently implement

    your JavaScript. • Don’t be afraid to cut the mustard (but not the cheese). • Treat all JavaScript as progressive enhancement and no-one will get hurt. • Re-think your interactions. Snazzy on desktop o!en means painful on mobile. • Polyfills, feature detection and conditional loaders can all be valuable tools when used sensibly. • Look beyond jQuery. Every bit of JS should have to justify it’s existence and size. • And never forget: With great power comes great responsivility.
  4. Cu ing the mustard* Not everyone really wants JavaScript in

    their life. * Catchy title not invented by me
  5. Some devices and browsers really suck at JavaScript • Poor

    standards support • Proxy browsers • Low memory, slow JS engines
  6. A higher bar is be"er than a lower one. Don’t

    be afraid to cut the mustard.
  7. — Wikipedia, October 2012 “Progressive enhancement uses web technologies in

    a layered fashion that allows everyone to access the basic content and functionality of a web page [...] while also providing an enhanced version of the page to those with more advanced browser so ware or greater bandwidth.”
  8. To polyfill, or not to polyfill? That is the question.

    • Respond.js • MatchMedia • PictureFill • Many others...
  9. Think mobile-first, polyfill as much as needed but as li"le

    as possible. Treat all JS as progressive enhancement.
  10. Use interactions appropriate to the context. On mobile native almost

    always beats non-native, JavaScript implementations. Snazzy on desktop often means painful on mobile.
  11. Conditional loading • JavaScript, CSS, HTML, Maps, images, everything! •

    Leave the core experience as minimal as possible, upgrade as necessary
  12. Other goodness • Polyfill media query support • Progressively enhance

    interactions • Be"er media queries (e.g. Selector Queries) • Improving server-side device detection (e.g. Detector)
  13. With conditional loading and responsive images we can deliver a

    lightweight, mobile-first site that scales up to desktop sizes. JS can help.
  14. Go micro! • Lots of great standalone micro libraries •

    Can stitch together with tools like RequireJS if needed • Can significantly improve filesize and also opens the door for more conditional loading
  15. Go custom! • Lots of plugins are pre"y bloated and

    not aimed at mobile as well as desktop • Writing your own can be very beneficial... but can take time and a lot of debugging.
  16. • Take time to reconsider the way you currently implement

    your JavaScript. • Don’t be afraid to cut the mustard (but not the cheese). • Treat all JavaScript as progressive enhancement and no-one will get hurt. • Re-think your interactions. Snazzy on desktop o!en means painful on mobile. • Polyfills, feature detection and conditional loaders can all be valuable tools when used sensibly. • Look beyond jQuery. Every bit of JS should have to justify it’s existence and size. • And never forget: With great power comes great responsivility.