SlideShare a Scribd company logo
1 of 13
Welcome to OS mobile JavaScript 
Tuesday September 8th 2014
What is JavaScript? 
 Client-side scripting that allows manipulation of 
the Document Object Model 
 DOM includes 
 CSS includes <link href="style.css/> 
 JS includes <script src="file.js"/> 
 All elements <div><h1>Title</h1></div> 
 All current browsers support it 
 If not disabled
What Mobile Needs 
 1 column layout 
 New navigation 
 Marketing tweaks 
 Fewer lines of JavaScript 
 No Flash media 
 No Mouse events 
 No Modals
Why JavaScript? 
 Fastest way for us to get mobile done 
 Good split of designer & developer time 
 No server configuration 
 No duplicate code or URLs 
 JavaScript already necessary 
 Tools already exist
Broad Overview 
 Check if they need mobile 
 White out the page 
 Reorganize things 
 Remove Desktop JavaScript 
 Alter HTML elements (add/delete/move) 
 Add Mobile CSS and JS 
 Render page
Who is Mobile? 
function useMobileView() { 
var d = document, c = d.cookie; 
if (d.documentElement.classList == undefined) return 0; 
if (c.indexOf("MobileView=") > -1) return (c.indexOf("MobileView=1") > -1); 
return screen.width <= 760; 
} 
 Browsers that support classList 
 Safari 5.1, Android 3, IE10, FF3.6, Chrome 8 
 Users with explicit cookies 
 Screen width of 760px or smaller
Mobify 
 Mobify is a paid service for turning Desktop 
websites mobile with Open Sourced JS 
 We modified the capture.js bit from their /src 
 https://github.com/mobify/mobifyjs 
 Process 
 Hides live DOM (w/ <plaintext 
style=”display:none”>) 
 Creates shadow DOM (w/ callback) 
 Replaces live DOM with shadow DOM (w/ callback)
Why Does it Work? 
 JavaScript is loaded/run as it happens 
 JavaScript doesn't care about the future, only 
the past 
 You can tell JavaScript to run after events 
happen, but that's outside the scope
Our JS Files 
 capture.js from Mobify 
 rebuild.js modifies the 
shadow DOM 
 loaded.js registers 
onload of the shadow 
DOM onload event 
 onload/*.js files do 
normal JS things
rebuild.js I 
 Activates Mobile CSS 
<link href="/css/everything.css?eba5c95" rel="mobile-style" 
type="text/css" id="jx_mobileStyles" /> 
Transmutes to 
<link href="/css/everything.css?eba5c95" rel="stylesheet" 
type="text/css" id="jx_mobileStyles" /> 
 Is put at the bottom of the HEAD 
 Overrides previous styles
rebuild.js I Code 
var head = doc.getElementsByTagName("head")[0]; 
// Activate mobile style sheet and place it 
// at the bottom of the head 
var style = doc.querySelector("#jx_mobileStyles"); 
style.setAttribute("rel", "stylesheet"); 
head.appendChild(style);
rebuild.js II 
 Removes JavaScript that the Desktop uses 
 Including MooTools and CeraBox 
 Any elements using the class 
“jx_desktopScripting” are removed 
Ex: 
<script type="text/javascript" 
src="/assets/js/mootools.js" 
class="jx_desktopScripting"></script>
rebuild.js II Code 
// Remove our desktop JavaScript 
var 
scripts=doc.getElementsByClassName("jx_desktopScri 
pting"); 
while(scripts.length > 0){ 
destroy(scripts[0]); 
} 
function destroy(node) { 
var parent = node.parentNode; 
if (node && parent) { 
parent.removeChild(node); 
} 
}

More Related Content

What's hot

A New Vue for Web Development
A New Vue for Web DevelopmentA New Vue for Web Development
A New Vue for Web DevelopmentChad Campbell
 
AngularJS - GrapeCity Echo Tokyo
AngularJS - GrapeCity Echo TokyoAngularJS - GrapeCity Echo Tokyo
AngularJS - GrapeCity Echo TokyoChris Bannon
 
[D2 오픈세미나]2.모바일웹디버깅
[D2 오픈세미나]2.모바일웹디버깅[D2 오픈세미나]2.모바일웹디버깅
[D2 오픈세미나]2.모바일웹디버깅NAVER D2
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3masahiroookubo
 
The 5 Layers of Web Accessibility
The 5 Layers of Web AccessibilityThe 5 Layers of Web Accessibility
The 5 Layers of Web AccessibilityDirk Ginader
 
JavaScript development methodology
JavaScript development methodologyJavaScript development methodology
JavaScript development methodologyAleksander Fabijan
 
jQuery Mobile - Desenvolvimento para dispositivos móveis
jQuery Mobile - Desenvolvimento para dispositivos móveisjQuery Mobile - Desenvolvimento para dispositivos móveis
jQuery Mobile - Desenvolvimento para dispositivos móveisPablo Garrido
 
Bliblidotcom - AngularJS Introduction
Bliblidotcom - AngularJS IntroductionBliblidotcom - AngularJS Introduction
Bliblidotcom - AngularJS IntroductionIrfan Maulana
 
Testable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascriptTestable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascriptTimothy Oxley
 
Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsJavascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsSoós Gábor
 

What's hot (20)

VueJS: The Simple Revolution
VueJS: The Simple RevolutionVueJS: The Simple Revolution
VueJS: The Simple Revolution
 
Jquery
JqueryJquery
Jquery
 
Jquery
JqueryJquery
Jquery
 
Vue js for beginner
Vue js for beginner Vue js for beginner
Vue js for beginner
 
Web Workers
Web WorkersWeb Workers
Web Workers
 
MEAN stack
MEAN stackMEAN stack
MEAN stack
 
A New Vue for Web Development
A New Vue for Web DevelopmentA New Vue for Web Development
A New Vue for Web Development
 
AngularJS - GrapeCity Echo Tokyo
AngularJS - GrapeCity Echo TokyoAngularJS - GrapeCity Echo Tokyo
AngularJS - GrapeCity Echo Tokyo
 
Single Page Applications
Single Page ApplicationsSingle Page Applications
Single Page Applications
 
[D2 오픈세미나]2.모바일웹디버깅
[D2 오픈세미나]2.모바일웹디버깅[D2 오픈세미나]2.모바일웹디버깅
[D2 오픈세미나]2.모바일웹디버깅
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3
 
BBUI
BBUIBBUI
BBUI
 
The 5 Layers of Web Accessibility
The 5 Layers of Web AccessibilityThe 5 Layers of Web Accessibility
The 5 Layers of Web Accessibility
 
JavaScript development methodology
JavaScript development methodologyJavaScript development methodology
JavaScript development methodology
 
jQuery Mobile - Desenvolvimento para dispositivos móveis
jQuery Mobile - Desenvolvimento para dispositivos móveisjQuery Mobile - Desenvolvimento para dispositivos móveis
jQuery Mobile - Desenvolvimento para dispositivos móveis
 
Web design services
Web design servicesWeb design services
Web design services
 
Webpack
Webpack Webpack
Webpack
 
Bliblidotcom - AngularJS Introduction
Bliblidotcom - AngularJS IntroductionBliblidotcom - AngularJS Introduction
Bliblidotcom - AngularJS Introduction
 
Testable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascriptTestable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascript
 
Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsJavascript frameworks: Backbone.js
Javascript frameworks: Backbone.js
 

Similar to Os mobile

JavaScript Performance (at SFJS)
JavaScript Performance (at SFJS)JavaScript Performance (at SFJS)
JavaScript Performance (at SFJS)Steve Souders
 
JavaScript Perfomance
JavaScript PerfomanceJavaScript Perfomance
JavaScript PerfomanceAnatol Alizar
 
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...tdc-globalcode
 
RESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsRESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsSven Wolfermann
 
Using RequireJS with CakePHP
Using RequireJS with CakePHPUsing RequireJS with CakePHP
Using RequireJS with CakePHPStephen Young
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest servicesIoan Eugen Stan
 
Modern Web Technologies
Modern Web TechnologiesModern Web Technologies
Modern Web TechnologiesPerttu Myry
 
phonegap with angular js for freshers
phonegap with angular js for freshers    phonegap with angular js for freshers
phonegap with angular js for freshers dssprakash
 
Web Development for UX Designers
Web Development for UX DesignersWeb Development for UX Designers
Web Development for UX DesignersAshlimarie
 
Introduction to jQuery Mobile
Introduction to jQuery MobileIntroduction to jQuery Mobile
Introduction to jQuery Mobileejlp12
 
J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012ghnash
 
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...Chartbeat
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenerytoddbr
 
Writing HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAEWriting HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAERon Reiter
 
Yeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsYeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsclimboid
 
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложенияCodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложенияCodeFest
 

Similar to Os mobile (20)

JavaScript Performance (at SFJS)
JavaScript Performance (at SFJS)JavaScript Performance (at SFJS)
JavaScript Performance (at SFJS)
 
JavaScript Perfomance
JavaScript PerfomanceJavaScript Perfomance
JavaScript Perfomance
 
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
 
RESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsRESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side Components
 
Using RequireJS with CakePHP
Using RequireJS with CakePHPUsing RequireJS with CakePHP
Using RequireJS with CakePHP
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
 
Modern Web Technologies
Modern Web TechnologiesModern Web Technologies
Modern Web Technologies
 
Taking your Web App for a walk
Taking your Web App for a walkTaking your Web App for a walk
Taking your Web App for a walk
 
phonegap with angular js for freshers
phonegap with angular js for freshers    phonegap with angular js for freshers
phonegap with angular js for freshers
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
 
Web Development for UX Designers
Web Development for UX DesignersWeb Development for UX Designers
Web Development for UX Designers
 
Introduction to jQuery Mobile
Introduction to jQuery MobileIntroduction to jQuery Mobile
Introduction to jQuery Mobile
 
J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012
 
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...
Tom Germeau: Mobile Apps: Finding the balance between performance and flexibi...
 
Fundaments of Knockout js
Fundaments of Knockout jsFundaments of Knockout js
Fundaments of Knockout js
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
Writing HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAEWriting HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAE
 
Yeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsYeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web apps
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложенияCodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
 

Os mobile

  • 1. Welcome to OS mobile JavaScript Tuesday September 8th 2014
  • 2. What is JavaScript?  Client-side scripting that allows manipulation of the Document Object Model  DOM includes  CSS includes <link href="style.css/>  JS includes <script src="file.js"/>  All elements <div><h1>Title</h1></div>  All current browsers support it  If not disabled
  • 3. What Mobile Needs  1 column layout  New navigation  Marketing tweaks  Fewer lines of JavaScript  No Flash media  No Mouse events  No Modals
  • 4. Why JavaScript?  Fastest way for us to get mobile done  Good split of designer & developer time  No server configuration  No duplicate code or URLs  JavaScript already necessary  Tools already exist
  • 5. Broad Overview  Check if they need mobile  White out the page  Reorganize things  Remove Desktop JavaScript  Alter HTML elements (add/delete/move)  Add Mobile CSS and JS  Render page
  • 6. Who is Mobile? function useMobileView() { var d = document, c = d.cookie; if (d.documentElement.classList == undefined) return 0; if (c.indexOf("MobileView=") > -1) return (c.indexOf("MobileView=1") > -1); return screen.width <= 760; }  Browsers that support classList  Safari 5.1, Android 3, IE10, FF3.6, Chrome 8  Users with explicit cookies  Screen width of 760px or smaller
  • 7. Mobify  Mobify is a paid service for turning Desktop websites mobile with Open Sourced JS  We modified the capture.js bit from their /src  https://github.com/mobify/mobifyjs  Process  Hides live DOM (w/ <plaintext style=”display:none”>)  Creates shadow DOM (w/ callback)  Replaces live DOM with shadow DOM (w/ callback)
  • 8. Why Does it Work?  JavaScript is loaded/run as it happens  JavaScript doesn't care about the future, only the past  You can tell JavaScript to run after events happen, but that's outside the scope
  • 9. Our JS Files  capture.js from Mobify  rebuild.js modifies the shadow DOM  loaded.js registers onload of the shadow DOM onload event  onload/*.js files do normal JS things
  • 10. rebuild.js I  Activates Mobile CSS <link href="/css/everything.css?eba5c95" rel="mobile-style" type="text/css" id="jx_mobileStyles" /> Transmutes to <link href="/css/everything.css?eba5c95" rel="stylesheet" type="text/css" id="jx_mobileStyles" />  Is put at the bottom of the HEAD  Overrides previous styles
  • 11. rebuild.js I Code var head = doc.getElementsByTagName("head")[0]; // Activate mobile style sheet and place it // at the bottom of the head var style = doc.querySelector("#jx_mobileStyles"); style.setAttribute("rel", "stylesheet"); head.appendChild(style);
  • 12. rebuild.js II  Removes JavaScript that the Desktop uses  Including MooTools and CeraBox  Any elements using the class “jx_desktopScripting” are removed Ex: <script type="text/javascript" src="/assets/js/mootools.js" class="jx_desktopScripting"></script>
  • 13. rebuild.js II Code // Remove our desktop JavaScript var scripts=doc.getElementsByClassName("jx_desktopScri pting"); while(scripts.length > 0){ destroy(scripts[0]); } function destroy(node) { var parent = node.parentNode; if (node && parent) { parent.removeChild(node); } }