Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
專題簡報2.pdf
Search
elliotlai
February 15, 2012
50
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
專題簡報2.pdf
elliotlai
February 15, 2012
More Decks by elliotlai
See All by elliotlai
課程組 '11 下
elliotlai
0
91
Featured
See All Featured
Discover your Explorer Soul
emna__ayadi
2
1.3k
How to make the Groovebox
asonas
2
2.5k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Abbi's Birthday
coloredviolet
4
10k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
940
Automating Front-end Workflow
addyosmani
1369
210k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
The Curious Case for Waylosing
cassininazir
1
570
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
870
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
260
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Transcript
自由軟體翻譯平台 組員:董孟鑫 9817123 賴廷彥 9917036 指導教授:楊武
Traditional web application
None
User Experience SUCKS HARD
Performance SUCKS HARD
Performance SUCKS HARD Unnecessary Data Re-transmission
we are building a TOOL
It has to be Handy
It has to be Handy Fast
It has to be Handy Fast Snappy
It has to be Handy Fast Snappy You meant SPA!
Single Page Application
everything in ONE single web page
how?
things servers are great at analytics HTML templating model behavior
proxying UI events security data persisting routing users
things servers are great at analytics HTML templating model behavior
proxying UI events security data persisting routing users
things browsers are great at HTML templating model behavior UI
events routing users
Challenges
"Forward/Back buttons are broken"
# HASH comes to rescue
fragment identifier #
fragment identifier # browser history recognizes this
"Search Engine Optimization"
SEO?
SEO? GET A LIFE!
# HASH
# HASHBANG !
!come-and-crowl-me #
!come-and-crowl-me # Google recognizes this
"SPA can't be used for heavy lifting"
None
None
twitter's got HASHBANG, too
SPA looks good
SPA looks good coding time!
tl;dr
spaghetti code!
It's all too easy to create JavaScript applications that end
up as tangled piles of jQuery selectors and callbacks
It's all too easy to create JavaScript applications that end
up as tangled piles of jQuery selectors and callbacks
front-end needs a MVC framework
front-end needs a MVC framework
UI events routing HTML templating Model behavior
FACT: front-end needs a MVC framework for sure
None
M V C
Model View Collection
Model View Collection Router
Model data logic surrounding it sync with backend
Collection collection of Models
View the TRUE controller UI events no views : )
Router URL routing events back-end-controller-ish
Event model.bind 'change', → //do something collection.bind 'add', (model) →
// ghrr
Sync newModel.save PUT oldModel.save POST collection.fetch GET model.destroy DELETE
Sync states with our RESTful back-end
read GET create POST update PUT delete DELETE /collection[/id] /collection
/collection/id /collection/id
As the project grows bigger
<script src="scripts/lib/jquery-1.7.1.min.js"></script> <script src="scripts/lib/underscore-min.js"></script> <script src="scripts/lib/backbone-min.js"></script> <script src="socket.io/socket.io.js"></script> <script src="scripts/models/apple.js"></script>
<script src="scripts/models/banana.js"></script> <script src="scripts/models/cat.js"></script> <script src="scripts/collections/apple.js"></script> <script src="scripts/collections/banana.js"></script> <script src="scripts/templates/sandvich.js"></script> <script src="scripts/views/apple.js"></script> <script src="scripts/views/banana.js"></script> …
dependency hell
we need a module loader
AMD comes to rescue
Asynchronous Module Definition
Asynchronous Module Definition a proposal of CommonJS Modules/Transport
Implementation: Require.js
require a module require ['lib/jquery'], ($) → $('...')
define a module define ['dependency'], (dep) → // do something
return something
specify the entry point <script data-main="scripts/main" src="scripts/require.js"></script>
dependencies loaded asynchronously <script data-main="scripts/main" src="scripts/require.js"></script> <script ... ></script> <script
... ></script> <script ... ></script> <script ... ></script>
Modularized! scripts/ lib/ jquery... backbone... ... models/ ... Collections/ ...
templates/ routers/ views/ main.js
other features optimization i18n bundle jsonp multiversion support …
How's our work then!?
We've just got our dev stack ready
Scripting DOM API MVC AMD Templating Stylesheets CoffeeScript jQuery Backbone.js
Require.js Mustache + Hogan.js SASS/Compass
Q&A