things i've learnt from my hacker news web app

35
Things I've learnt from my Things I've learnt from my Hacker News web app Hacker News web app

Upload: chee-aun-lim

Post on 08-May-2015

4.589 views

Category:

Documents


1 download

DESCRIPTION

A talk I gave at the Front-end Developers User Group meet up in Hackerspace SG.

TRANSCRIPT

Page 1: Things I've learnt from my Hacker News web app

Things I've learnt from myThings I've learnt from myHacker News web appHacker News web app

Page 2: Things I've learnt from my Hacker News web app

Hello, I'm Chee Aun.• Hardcore web developer.

• Created quite a bunch of fun little side projects.

• Tweet a lot of interesting stuff at @cheeaun

• Occasionally read Hacker News.

Page 3: Things I've learnt from my Hacker News web app

What isHacker News?

Page 4: Things I've learnt from my Hacker News web app

news.ycombinator.comnews.ycombinator.com

Page 5: Things I've learnt from my Hacker News web app

I builtHackerWeb.

Page 6: Things I've learnt from my Hacker News web app

HackerWeb• A simple read-only web app client for Hacker News.

• Mobile-optimized, iOS-optimized.

• Works on all modern browsers, hopefully.

• Check it out at hackerwebapp.com

Page 7: Things I've learnt from my Hacker News web app
Page 8: Things I've learnt from my Hacker News web app
Page 9: Things I've learnt from my Hacker News web app
Page 10: Things I've learnt from my Hacker News web app

Cutting-edge web tech-webkit-overflow-scrolling: touch, localStorage,

sessionStorage, CORS, Application Cache, CSS

Animation, CSS Media Queries, Flexible Box Layout

(old spec), requestAnimationFrame, Web Workers,

and more…

Page 11: Things I've learnt from my Hacker News web app

Must-reads• How I built the Hacker News mobile web app

• How I built the Hacker News mobile web app, Part 2

• Introducing HackerWeb

Page 12: Things I've learnt from my Hacker News web app

Focus on 3 things1. -webkit-overflow-scrolling: touch

(Momentum scrolling)

2. CORS (Cross-Origin Resource Sharing)

3. Application Cache

Page 13: Things I've learnt from my Hacker News web app

1

Momentumscrolling

Page 14: Things I've learnt from my Hacker News web app

-webkit-overflow-scrolling:touch

• iOS-specific, for now. No official spec.

• Introduced since iOS5 (October 2011).

• For overflow:scroll elements.

Page 15: Things I've learnt from my Hacker News web app

Before iOS5• Two fingers to scroll overflow:scroll

elements.

• Unintuitive and undiscoverable.

• Scrolling libs to the rescue: iScroll, Scrollability,

TouchScroll, FTScroller, etc

Page 16: Things I've learnt from my Hacker News web app

Starting from iOS5• One finger to scroll overflow:scroll elements.

• -webkit-overflow-scrolling: touch

adds momentum to it.

• Scrolling libs are still in used due to bugs/quirks.

• Bug: Can't scroll to top when tapping status bar

Page 17: Things I've learnt from my Hacker News web app

Demo time• Normal scrolling: jsbin.com/uhiyac/1

• Momentum scrolling: jsbin.com/uhiyac/2

Page 18: Things I've learnt from my Hacker News web app

Resources• Overthrow – overflow:auto polyfill

• jQuery Mobile: touchOverflow

• Nested divs with overflow:touch

Page 19: Things I've learnt from my Hacker News web app

2

CORS

Page 20: Things I've learnt from my Hacker News web app

Before CORS• Use JSONP.

• Request data from a server in a different domain.

• Example: json-head.appspot.com/?

url=http://www.google.com/&callback=test

• A “hack”.

Page 21: Things I've learnt from my Hacker News web app

CORS• A W3C Working Draft.

• Allow JavaScript to make cross-domain requests.

• An interplay between the server and the client.

Access-Control-Allow-Origin: *

Page 22: Things I've learnt from my Hacker News web app

Use CORStoday!

Page 24: Things I've learnt from my Hacker News web app

Resources• Enable CORS

• CORS isn’t just for XHR

• Can I use CORS?

• Using CORS - HTML5 Rocks

• CORS Proxy

Page 25: Things I've learnt from my Hacker News web app

3

ApplicationCache

Page 26: Things I've learnt from my Hacker News web app

AppCache• Easily make your web site/app offline.

• A working draft.

• A douchebag.

Page 27: Things I've learnt from my Hacker News web app

Super simple stepsStep 1.

<html manifest="manifest.appcache">

Step 2.

CACHE MANIFESTindex.htmlstylesheet.css…

Page 28: Things I've learnt from my Hacker News web app

VersioningCACHE MANIFEST# 2013-01-21:v1

index.htmlstylesheet.css…

Page 29: Things I've learnt from my Hacker News web app

Google Reader

Page 30: Things I've learnt from my Hacker News web app

Reeddit – Reddit web app client

Page 31: Things I've learnt from my Hacker News web app

Track AppCache versionsUse Google Analytics' event tracking

Page 32: Things I've learnt from my Hacker News web app

Make local dev easier• Serve 404 for .appcache files

• For HackerWeb, I use node server.js

-noappcache

Page 33: Things I've learnt from my Hacker News web app

Resources• A Beginner's Guide to Using the Application Cache

• Fixing Application Cache Community Group

• Appcache Facts

Page 34: Things I've learnt from my Hacker News web app

More resources• Moobile – new mobile application framework built

on MooTools

• Ratchet – Prototype iPhone apps with simple HTML,

CSS and JS components

• HTML5 Rocks

• Can I use…

Page 35: Things I've learnt from my Hacker News web app

Thanks• cheeaun.com

• twitter.com/cheeaun

• github.com/cheeaun

Images used in this presentation

• flickr.com/photos/diathesis/2262012694/