SlideShare a Scribd company logo
Client-side Transformations



                    @johnboxall
                         @vanjs
                    march 9 2011
What are client-side transformations?
What are client-side transformations?
      Transforming a webpage.
         On the client side.
Taking your content...

  <html>
      <body>
        <h1>one</h1>
        <h2>two</h2>
      <body>
  </html>
Taking your content... and remixing it!

  <html>                    <html>
      <body>                <body>
        <h1>one</h1>            <h2>two</h2>
        <h2>two</h2>            <h1>one</h1>
      <body>                <body>
  </html>                   </html>
Why would you ever want to do this?
Why would you ever want to do this?

Because you make mobile websites!
To make mobile websites we used to do this




 PHONE              PROXY           CONTENT
To make mobile websites we used to do this
• good                  • bad
• layout control        • politics
• resource control      • operations



  PHONE              PROXY             CONTENT
Client-side transformations let us do this



                       JS




  PHONE              PROXY             CONTENT
Client-side transformations let us do this
Client-side transformations let us do this
• good                      • bad
• layout control            • ???
• resource control

                       JS




  PHONE                                CONTENT
How should we implement layout control?


  <html>                 <html>
     <body>              <body>
       <h1>one</h1>         <h2>two</h2>
       <h2>two</h2>         <h1>one</h1>
     <body>              <body>
  </html>                </html>
How should we implement layout control?


  <html>

    <body>

     <h1>One</h1>

     <h2>Two</h1>

      <script type="text/javascript">
             $('h2').before('h1');
      </script>
    </body>

  </html>
How should we implement layout control?
  <html>
    <body>
      <script type="text/javascript">
        var $body = $('body').hide();
      </script>
     <h1>One</h1>
     <h2>Two</h1>
      <script type="text/javascript">
        $(function() {
             $('h2').before($('h1'));
             $body.show();
        });
      </script>

    </body>
  </html>
How can we implement resource control?

  <html>

  <body>

  <script type="text/javascript" src="one.js"></script>

  <script type="text/javascript" src="two.js"></script>




  </body>

  </html>
How can we implement resource control?

  <html>

  <body>

  <script type="text/javascript" src="one.js"></script>

  <script type="text/javascript" src="two.js"></script>

  <script type="text/javascript">

   $('[src="one.js"]').before($('[src="two.js"]'));

  </script>

  </body>

  </html>
How can we implement resource control?



<script type="text/javascript">
  var $doc = $(document).bind('beforeload', function(e) {
      e.preventDefault();
    });
</script>
How can we implement resource control?
  <html>
  <body>
  <script type="text/javascript">
   var scripts = [];
   var $doc = $(document).bind('beforeload', function(e) {
         scripts.push(e.target);
         e.preventDefault();
     });

   $(function() {
     $doc.unbind('beforeload');
     (function loadScripts() {
         var script = scripts.pop();
         if (script) $.getScript(script.src, loadScripts);
     })();
   });
  </script>
  <script type="text/javascript" src="one.js"></script>
  <script type="text/javascript" src="two.js"></script>
  </body>
  </html>
How can we implement resource control?
  <html>
  <body>
  <script type="text/javascript">
   var scripts = [];
   var $doc = $(document).bind('beforeload', function(e) {
         scripts.push(e.target);
         e.preventDefault();
     });

   $(function() {
     $doc.unbind('beforeload');
     (function loadScript() {
         var script = scripts.pop();
         if (script) $.getScript(script.src, loadScript);
     })();
   });
  </script>
  <script type="text/javascript" src="one.js"></script>
  <script type="text/javascript" src="two.js"></script>
  </body>
  </html>
How can we implement resource control?
  <html>
  <body>
  <script type="text/javascript">
   var scripts = [];
   var $doc = $(document).bind('beforeload', function(e) {
         scripts.push(e.target);
         e.preventDefault();
     });

   $(function() {
     $doc.unbind('beforeload');
     (function loadScript() {
         var script = scripts.pop();
         if (script) $.getScript(script.src, loadScript);
     })();
   });
  </script>
  <script type="text/javascript">alert('one');</script>
  <script type="text/javascript">alert('two');</script>
  </body>
  </html>
How can we implement resource control?



 <script type="text/x-javascript">alert('one');</script>
How can we implement resource control?
<html>
<body>
 <noscript>



  <script type="text/javascript">alert('one');</script>
  <script type="text/javascript">alert('two');</script>
 </noscript>
</body>
</html>
How can we implement resource control?
<html>
<body>
 <script type="text/javascript">
   document.write('x3Cnoscript>');
 </script>
  <script type="text/javascript">alert('one');</script>
  <script type="text/javascript">alert('two');</script>
 </noscript>
</body>
</html>
How can we implement resource control?
<html>
<body>
 <script type="text/javascript">
   document.write('x3Cnoscript>');
 </script>
  <script type="text/javascript">alert('one');</script>
  <script type="text/javascript">alert('two');</script>
 </noscript>
</body>
</html>
How can we implement resource control?
<html>
<body>
 <script type="text/javascript">
   document.write('x3Cnoscript>');
 </script>
  <script type="text/javascript">alert('one');</script>
  <script type="text/javascript">alert('two');</script>
 </noscript>
</body>
</html>
How can we implement resource control?
<html>
<body>
 <script type="text/javascript">
   document.write('x3Cstyle type="text/x-css">');
 </script>
  <script type="text/javascript">alert('one');</script>
  <script type="text/javascript">alert('two');</script>
 </style>
</body>
</html>
How can we implement resource control?
<html>
<body>
 <script type="text/javascript">
   document.write('x3Cstyle type="text/x-css">');
 </script>
  <script type="text/javascript">alert('one');</script>
  <script type="text/javascript">alert('two');</script>
 </style>
 <script type="text/javascript">
   var $scripts = $($('style').html());
   $scripts.reverse();
   $('body').append($scripts);
 </script>
</body>
</html>
X Layout control

X Resource control
Let’s build a mobile site using CST.
var $content = $($('style').html());


var context = {
      '#title': $('h1', $content),
        '#price': $(div.price, $content).html(),
        '#sizes': (function() {
          return $('#size', $content);
        })
    }


var templateStr = [
        '<div id="title"></div>',
        '<div id="price"></div>',
        '<div id="sizes"></div>'
    ].join('');


var $transform = $.template(templateStr, context);


$('body').append($transform);
var $content = $($('style').html());


var context = {
      '#title': $('h1', $content),
        '#price': $(div.price, $content).html(),
        '#sizes': (function() {
          return $('#size', $content);
        })
    }


var templateStr = [
        '<div id="title"></div>',
        '<div id="price"></div>',
        '<div id="sizes"></div>'
    ].join('');


var $transform = $.template(templateStr, context);


$('body').append($transform);
var $content = $($('style').html());


var context = {
      '#title': $('h1', $content),
        '#price': $(div.price, $content).html(),
        '#sizes': (function() {
          return $('#size', $content);
        })
    }


var templateStr = [
        '<div id="title"></div>',
        '<div id="price"></div>',
        '<div id="sizes"></div>'
    ].join('');


var $transform = $.template(templateStr, context);


$('body').append($transform);
var $content = $($('style').html());


var context = {
      '#title': $('h1', $content),
        '#price': $(div.price, $content).html(),
        '#sizes': (function() {
          return $('#size', $content);
        })
    }


var templateStr = [
        '<div id="title"></div>',
        '<div id="price"></div>',
        '<div id="sizes"></div>'
    ].join('');


var $transform = $.template(templateStr, context);


$('body').append($transform);
Client-side Transformations
       PS. We’re hiring:

    http://mobify.me/jobs/
                           @johnboxall
                                @vanjs
                           march 9 2011

More Related Content

What's hot

Opencast Admin UI - Introduction to developing using AngularJS
Opencast Admin UI - Introduction to developing using AngularJSOpencast Admin UI - Introduction to developing using AngularJS
Opencast Admin UI - Introduction to developing using AngularJS
buttyx
 
Jquery
JqueryJquery
JavaScript and jQuery Basics
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery Basics
Kaloyan Kosev
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
Shumpei Shiraishi
 
Jquery examples
Jquery examplesJquery examples
Jquery examples
programmingslides
 
Dart and AngularDart
Dart and AngularDartDart and AngularDart
Dart and AngularDart
Loc Nguyen
 
Client Web
Client WebClient Web
Client Web
Markiyan Matsekh
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
Bedis ElAchèche
 
`From Prototype to Drupal` by Andrew Ivasiv
`From Prototype to Drupal` by Andrew Ivasiv`From Prototype to Drupal` by Andrew Ivasiv
`From Prototype to Drupal` by Andrew Ivasiv
Lemberg Solutions
 
jQuery Best Practice
jQuery Best Practice jQuery Best Practice
jQuery Best Practice
chandrashekher786
 
Dynamic documentation - SRECON 2017
Dynamic documentation - SRECON 2017Dynamic documentation - SRECON 2017
Dynamic documentation - SRECON 2017
Daniel ( Danny ) ☃ Lawrence
 
GDI Seattle - Intro to JavaScript Class 4
GDI Seattle - Intro to JavaScript Class 4GDI Seattle - Intro to JavaScript Class 4
GDI Seattle - Intro to JavaScript Class 4
Heather Rock
 
jQuery PPT
jQuery PPTjQuery PPT
jQuery PPT
Dominic Arrojado
 
Get AngularJS Started!
Get AngularJS Started!Get AngularJS Started!
Get AngularJS Started!
Dzmitry Ivashutsin
 
jQuery Presentation to Rails Developers
jQuery Presentation to Rails DevelopersjQuery Presentation to Rails Developers
jQuery Presentation to Rails Developers
Yehuda Katz
 
Solr and symfony in Harmony with SolrJs
Solr and symfony in Harmony with SolrJsSolr and symfony in Harmony with SolrJs
Solr and symfony in Harmony with SolrJsWildan Maulana
 
Java script
Java scriptJava script
Java script
Sukrit Gupta
 
Prototype & jQuery
Prototype & jQueryPrototype & jQuery
Prototype & jQuery
Remy Sharp
 
Merb jQuery
Merb jQueryMerb jQuery
Merb jQuery
Yehuda Katz
 

What's hot (20)

Opencast Admin UI - Introduction to developing using AngularJS
Opencast Admin UI - Introduction to developing using AngularJSOpencast Admin UI - Introduction to developing using AngularJS
Opencast Admin UI - Introduction to developing using AngularJS
 
Jquery
JqueryJquery
Jquery
 
JavaScript and jQuery Basics
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery Basics
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
 
Jquery examples
Jquery examplesJquery examples
Jquery examples
 
Dart and AngularDart
Dart and AngularDartDart and AngularDart
Dart and AngularDart
 
J query training
J query trainingJ query training
J query training
 
Client Web
Client WebClient Web
Client Web
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 
`From Prototype to Drupal` by Andrew Ivasiv
`From Prototype to Drupal` by Andrew Ivasiv`From Prototype to Drupal` by Andrew Ivasiv
`From Prototype to Drupal` by Andrew Ivasiv
 
jQuery Best Practice
jQuery Best Practice jQuery Best Practice
jQuery Best Practice
 
Dynamic documentation - SRECON 2017
Dynamic documentation - SRECON 2017Dynamic documentation - SRECON 2017
Dynamic documentation - SRECON 2017
 
GDI Seattle - Intro to JavaScript Class 4
GDI Seattle - Intro to JavaScript Class 4GDI Seattle - Intro to JavaScript Class 4
GDI Seattle - Intro to JavaScript Class 4
 
jQuery PPT
jQuery PPTjQuery PPT
jQuery PPT
 
Get AngularJS Started!
Get AngularJS Started!Get AngularJS Started!
Get AngularJS Started!
 
jQuery Presentation to Rails Developers
jQuery Presentation to Rails DevelopersjQuery Presentation to Rails Developers
jQuery Presentation to Rails Developers
 
Solr and symfony in Harmony with SolrJs
Solr and symfony in Harmony with SolrJsSolr and symfony in Harmony with SolrJs
Solr and symfony in Harmony with SolrJs
 
Java script
Java scriptJava script
Java script
 
Prototype & jQuery
Prototype & jQueryPrototype & jQuery
Prototype & jQuery
 
Merb jQuery
Merb jQueryMerb jQuery
Merb jQuery
 

Viewers also liked

τα Olpc xo
τα Olpc xoτα Olpc xo
τα Olpc xo
Sotiris Terzidis
 
App Day - Show Your App Award - LOCA
App Day - Show Your App Award - LOCAApp Day - Show Your App Award - LOCA
App Day - Show Your App Award - LOCA
Feigl
 
Os 10 mandamentos
Os 10 mandamentosOs 10 mandamentos
Os 10 mandamentos27priscila
 
Vinde, adoremos!
Vinde, adoremos!Vinde, adoremos!
Vinde, adoremos!
Thatiane Machado da Silva
 
Health and Personal Care
Health and Personal CareHealth and Personal Care
Health and Personal Care
Ramona Warner
 
Saber Amar
Saber AmarSaber Amar
Saber Amarcab3032
 
Ilusãodeótica
IlusãodeóticaIlusãodeótica
Ilusãodeóticageorgoeme
 
Staffing officer kpi
Staffing officer kpiStaffing officer kpi
Staffing officer kpicadasjom
 
BOLETIM GRALHA AZUL NO. 47 - SOBRAMES - PR - JUNHO 2014
BOLETIM GRALHA AZUL NO. 47 - SOBRAMES - PR - JUNHO 2014BOLETIM GRALHA AZUL NO. 47 - SOBRAMES - PR - JUNHO 2014
BOLETIM GRALHA AZUL NO. 47 - SOBRAMES - PR - JUNHO 2014
Sérgio Pitaki
 
Decepcao
DecepcaoDecepcao

Viewers also liked (20)

τα Olpc xo
τα Olpc xoτα Olpc xo
τα Olpc xo
 
Hangouts
HangoutsHangouts
Hangouts
 
App Day - Show Your App Award - LOCA
App Day - Show Your App Award - LOCAApp Day - Show Your App Award - LOCA
App Day - Show Your App Award - LOCA
 
Joanlatorre
JoanlatorreJoanlatorre
Joanlatorre
 
Os 10 mandamentos
Os 10 mandamentosOs 10 mandamentos
Os 10 mandamentos
 
Vinde, adoremos!
Vinde, adoremos!Vinde, adoremos!
Vinde, adoremos!
 
Health and Personal Care
Health and Personal CareHealth and Personal Care
Health and Personal Care
 
Saber Amar
Saber AmarSaber Amar
Saber Amar
 
BiblioAnimação julho
BiblioAnimação julhoBiblioAnimação julho
BiblioAnimação julho
 
Que diras
Que dirasQue diras
Que diras
 
Ilusãodeótica
IlusãodeóticaIlusãodeótica
Ilusãodeótica
 
Staffing officer kpi
Staffing officer kpiStaffing officer kpi
Staffing officer kpi
 
La bimba
La  bimbaLa  bimba
La bimba
 
Mateus 028
Mateus   028Mateus   028
Mateus 028
 
Salud
SaludSalud
Salud
 
BOLETIM GRALHA AZUL NO. 47 - SOBRAMES - PR - JUNHO 2014
BOLETIM GRALHA AZUL NO. 47 - SOBRAMES - PR - JUNHO 2014BOLETIM GRALHA AZUL NO. 47 - SOBRAMES - PR - JUNHO 2014
BOLETIM GRALHA AZUL NO. 47 - SOBRAMES - PR - JUNHO 2014
 
Sap modules standard
Sap modules standardSap modules standard
Sap modules standard
 
Genesis 40
Genesis 40Genesis 40
Genesis 40
 
Decepcao
DecepcaoDecepcao
Decepcao
 
Apresentação aldeia
Apresentação aldeiaApresentação aldeia
Apresentação aldeia
 

Similar to Client-side Transformations

Yearning jQuery
Yearning jQueryYearning jQuery
Yearning jQueryRemy Sharp
 
Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap
Rakesh Jha
 
jQuery
jQueryjQuery
jQuery basics
jQuery basicsjQuery basics
jQuery basics
Stijn Van Minnebruggen
 
Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" Domino
Rob Bontekoe
 
jQuery
jQueryjQuery
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
Jens-Christian Fischer
 
Desenvolvimento web com jQuery Mobile
Desenvolvimento web com jQuery MobileDesenvolvimento web com jQuery Mobile
Desenvolvimento web com jQuery Mobile
Pablo Garrido
 
JavaScript Training
JavaScript TrainingJavaScript Training
JavaScript Training
Ramindu Deshapriya
 
Better Selenium Tests with Geb - Selenium Conf 2014
Better Selenium Tests with Geb - Selenium Conf 2014Better Selenium Tests with Geb - Selenium Conf 2014
Better Selenium Tests with Geb - Selenium Conf 2014
Naresha K
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Collaboration Technologies
 
Practical HTML5: Using It Today
Practical HTML5: Using It TodayPractical HTML5: Using It Today
Practical HTML5: Using It Today
Doris Chen
 
HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2James Pearce
 
Unit – II (1).pptx
Unit – II (1).pptxUnit – II (1).pptx
Unit – II (1).pptx
DrDhivyaaCRAssistant
 
jQuery Mobile: For Fun and Profit
jQuery Mobile: For Fun and ProfitjQuery Mobile: For Fun and Profit
jQuery Mobile: For Fun and Profit
Daniel Cousineau
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsAlessandro Molina
 
Why You Should be Using Web Components Right Now. And How. ForwardJS July 2015
Why You Should be Using Web Components Right Now. And How. ForwardJS July 2015Why You Should be Using Web Components Right Now. And How. ForwardJS July 2015
Why You Should be Using Web Components Right Now. And How. ForwardJS July 2015
Phil Leggetter
 
Course CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.jsCourse CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.js
Vinícius de Moraes
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksJavascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksHjörtur Hilmarsson
 

Similar to Client-side Transformations (20)

Yearning jQuery
Yearning jQueryYearning jQuery
Yearning jQuery
 
Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap
 
jQuery
jQueryjQuery
jQuery
 
jQuery basics
jQuery basicsjQuery basics
jQuery basics
 
Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" Domino
 
jQuery
jQueryjQuery
jQuery
 
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
 
Desenvolvimento web com jQuery Mobile
Desenvolvimento web com jQuery MobileDesenvolvimento web com jQuery Mobile
Desenvolvimento web com jQuery Mobile
 
JavaScript Training
JavaScript TrainingJavaScript Training
JavaScript Training
 
Better Selenium Tests with Geb - Selenium Conf 2014
Better Selenium Tests with Geb - Selenium Conf 2014Better Selenium Tests with Geb - Selenium Conf 2014
Better Selenium Tests with Geb - Selenium Conf 2014
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Practical HTML5: Using It Today
Practical HTML5: Using It TodayPractical HTML5: Using It Today
Practical HTML5: Using It Today
 
HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2HTML5 and the dawn of rich mobile web applications pt 2
HTML5 and the dawn of rich mobile web applications pt 2
 
Unit – II (1).pptx
Unit – II (1).pptxUnit – II (1).pptx
Unit – II (1).pptx
 
HTML5
HTML5HTML5
HTML5
 
jQuery Mobile: For Fun and Profit
jQuery Mobile: For Fun and ProfitjQuery Mobile: For Fun and Profit
jQuery Mobile: For Fun and Profit
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
 
Why You Should be Using Web Components Right Now. And How. ForwardJS July 2015
Why You Should be Using Web Components Right Now. And How. ForwardJS July 2015Why You Should be Using Web Components Right Now. And How. ForwardJS July 2015
Why You Should be Using Web Components Right Now. And How. ForwardJS July 2015
 
Course CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.jsCourse CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.js
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksJavascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & Tricks
 

Recently uploaded

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
ViralQR
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 

Recently uploaded (20)

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 

Client-side Transformations

  • 1. Client-side Transformations @johnboxall @vanjs march 9 2011
  • 2. What are client-side transformations?
  • 3. What are client-side transformations? Transforming a webpage. On the client side.
  • 4. Taking your content... <html> <body> <h1>one</h1> <h2>two</h2> <body> </html>
  • 5. Taking your content... and remixing it! <html> <html> <body> <body> <h1>one</h1> <h2>two</h2> <h2>two</h2> <h1>one</h1> <body> <body> </html> </html>
  • 6. Why would you ever want to do this?
  • 7. Why would you ever want to do this? Because you make mobile websites!
  • 8. To make mobile websites we used to do this PHONE PROXY CONTENT
  • 9. To make mobile websites we used to do this • good • bad • layout control • politics • resource control • operations PHONE PROXY CONTENT
  • 10. Client-side transformations let us do this JS PHONE PROXY CONTENT
  • 12. Client-side transformations let us do this • good • bad • layout control • ??? • resource control JS PHONE CONTENT
  • 13. How should we implement layout control? <html> <html> <body> <body> <h1>one</h1> <h2>two</h2> <h2>two</h2> <h1>one</h1> <body> <body> </html> </html>
  • 14. How should we implement layout control? <html> <body> <h1>One</h1> <h2>Two</h1> <script type="text/javascript"> $('h2').before('h1'); </script> </body> </html>
  • 15. How should we implement layout control? <html> <body> <script type="text/javascript"> var $body = $('body').hide(); </script> <h1>One</h1> <h2>Two</h1> <script type="text/javascript"> $(function() { $('h2').before($('h1')); $body.show(); }); </script> </body> </html>
  • 16. How can we implement resource control? <html> <body> <script type="text/javascript" src="one.js"></script> <script type="text/javascript" src="two.js"></script> </body> </html>
  • 17. How can we implement resource control? <html> <body> <script type="text/javascript" src="one.js"></script> <script type="text/javascript" src="two.js"></script> <script type="text/javascript"> $('[src="one.js"]').before($('[src="two.js"]')); </script> </body> </html>
  • 18. How can we implement resource control? <script type="text/javascript"> var $doc = $(document).bind('beforeload', function(e) { e.preventDefault(); }); </script>
  • 19. How can we implement resource control? <html> <body> <script type="text/javascript"> var scripts = []; var $doc = $(document).bind('beforeload', function(e) { scripts.push(e.target); e.preventDefault(); }); $(function() { $doc.unbind('beforeload'); (function loadScripts() { var script = scripts.pop(); if (script) $.getScript(script.src, loadScripts); })(); }); </script> <script type="text/javascript" src="one.js"></script> <script type="text/javascript" src="two.js"></script> </body> </html>
  • 20. How can we implement resource control? <html> <body> <script type="text/javascript"> var scripts = []; var $doc = $(document).bind('beforeload', function(e) { scripts.push(e.target); e.preventDefault(); }); $(function() { $doc.unbind('beforeload'); (function loadScript() { var script = scripts.pop(); if (script) $.getScript(script.src, loadScript); })(); }); </script> <script type="text/javascript" src="one.js"></script> <script type="text/javascript" src="two.js"></script> </body> </html>
  • 21. How can we implement resource control? <html> <body> <script type="text/javascript"> var scripts = []; var $doc = $(document).bind('beforeload', function(e) { scripts.push(e.target); e.preventDefault(); }); $(function() { $doc.unbind('beforeload'); (function loadScript() { var script = scripts.pop(); if (script) $.getScript(script.src, loadScript); })(); }); </script> <script type="text/javascript">alert('one');</script> <script type="text/javascript">alert('two');</script> </body> </html>
  • 22. How can we implement resource control? <script type="text/x-javascript">alert('one');</script>
  • 23. How can we implement resource control? <html> <body> <noscript> <script type="text/javascript">alert('one');</script> <script type="text/javascript">alert('two');</script> </noscript> </body> </html>
  • 24. How can we implement resource control? <html> <body> <script type="text/javascript"> document.write('x3Cnoscript>'); </script> <script type="text/javascript">alert('one');</script> <script type="text/javascript">alert('two');</script> </noscript> </body> </html>
  • 25. How can we implement resource control? <html> <body> <script type="text/javascript"> document.write('x3Cnoscript>'); </script> <script type="text/javascript">alert('one');</script> <script type="text/javascript">alert('two');</script> </noscript> </body> </html>
  • 26. How can we implement resource control? <html> <body> <script type="text/javascript"> document.write('x3Cnoscript>'); </script> <script type="text/javascript">alert('one');</script> <script type="text/javascript">alert('two');</script> </noscript> </body> </html>
  • 27. How can we implement resource control? <html> <body> <script type="text/javascript"> document.write('x3Cstyle type="text/x-css">'); </script> <script type="text/javascript">alert('one');</script> <script type="text/javascript">alert('two');</script> </style> </body> </html>
  • 28. How can we implement resource control? <html> <body> <script type="text/javascript"> document.write('x3Cstyle type="text/x-css">'); </script> <script type="text/javascript">alert('one');</script> <script type="text/javascript">alert('two');</script> </style> <script type="text/javascript"> var $scripts = $($('style').html()); $scripts.reverse(); $('body').append($scripts); </script> </body> </html>
  • 29. X Layout control X Resource control
  • 30. Let’s build a mobile site using CST.
  • 31. var $content = $($('style').html()); var context = { '#title': $('h1', $content), '#price': $(div.price, $content).html(), '#sizes': (function() { return $('#size', $content); }) } var templateStr = [ '<div id="title"></div>', '<div id="price"></div>', '<div id="sizes"></div>' ].join(''); var $transform = $.template(templateStr, context); $('body').append($transform);
  • 32. var $content = $($('style').html()); var context = { '#title': $('h1', $content), '#price': $(div.price, $content).html(), '#sizes': (function() { return $('#size', $content); }) } var templateStr = [ '<div id="title"></div>', '<div id="price"></div>', '<div id="sizes"></div>' ].join(''); var $transform = $.template(templateStr, context); $('body').append($transform);
  • 33. var $content = $($('style').html()); var context = { '#title': $('h1', $content), '#price': $(div.price, $content).html(), '#sizes': (function() { return $('#size', $content); }) } var templateStr = [ '<div id="title"></div>', '<div id="price"></div>', '<div id="sizes"></div>' ].join(''); var $transform = $.template(templateStr, context); $('body').append($transform);
  • 34. var $content = $($('style').html()); var context = { '#title': $('h1', $content), '#price': $(div.price, $content).html(), '#sizes': (function() { return $('#size', $content); }) } var templateStr = [ '<div id="title"></div>', '<div id="price"></div>', '<div id="sizes"></div>' ].join(''); var $transform = $.template(templateStr, context); $('body').append($transform);
  • 35. Client-side Transformations PS. We’re hiring: http://mobify.me/jobs/ @johnboxall @vanjs march 9 2011

Editor's Notes

  1. \n
  2. The ability to transform the way a webpage is loaded by the client.\n
  3. The ability to transform the way a webpage is loaded by the client.\n
  4. SHOW ME\n
  5. Totally remix the page.\nUse existing components - or don&amp;#x2019;t\nHoney Badger - it just care. We don&amp;#x2019;t care about your original HTML. (but we could if we wanted to)\n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. Why didn&amp;#x2019;t you just do this in the beginning\n
  12. \n
  13. So we got this, how are we actually gonna make it work?\n
  14. So we got this, how are we actually gonna make it work?\n
  15. So we got this, how are we actually gonna make it work?\n
  16. So we got this, how are we actually gonna make it work?\n
  17. So we got this, how are we actually gonna make it work?\n
  18. http://developer.apple.com/library/safari/#documentation/Tools/Conceptual/SafariExtensionGuide/MessagesandProxies/MessagesandProxies.html#//apple_ref/doc/uid/TP40009977-CH14-SW9\n
  19. \n
  20. \n
  21. \n
  22. \n
  23. So ... can we do that dynamcially?\n
  24. So ... can we do that dynamcially?\n
  25. So ... can we do that dynamcially?\n
  26. So ... can we do that dynamcially?\n
  27. So ... can we do that dynamcially?\n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n