SlideShare ist ein Scribd-Unternehmen logo
1 von 35
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

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (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
 

Andere mochten auch (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
 

Ähnlich wie 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
 
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" DominoRob Bontekoe
 
Desenvolvimento web com jQuery Mobile
Desenvolvimento web com jQuery MobileDesenvolvimento web com jQuery Mobile
Desenvolvimento web com jQuery MobilePablo Garrido
 
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 2014Naresha K
 
Practical HTML5: Using It Today
Practical HTML5: Using It TodayPractical HTML5: Using It Today
Practical HTML5: Using It TodayDoris 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
 
jQuery Mobile: For Fun and Profit
jQuery Mobile: For Fun and ProfitjQuery Mobile: For Fun and Profit
jQuery Mobile: For Fun and ProfitDaniel 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 2015Phil 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.jsVinícius de Moraes
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksJavascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksHjörtur Hilmarsson
 

Ähnlich wie 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
 

Kürzlich hochgeladen

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 

Kürzlich hochgeladen (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

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

Hinweis der Redaktion

  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