SlideShare a Scribd company logo
DR. STRANGELOVE OR:
 HOW I LEARNED TO STOP
  WORRYING AND LOVE
HTML, CSS, AND JAVASCRIPT
BJ CLARK
UX Developer @ http://goldstar.com


       @RobotDeathSquad
      http://github.com/BJClark
          http://bjclark.me
POP QUIZ!!!!
Dr. Strangelove or: How I learned to stop worrying and love HTML, CSS and Javascript
git clone git://github.com/BJClark/Dr.-Strangelove.git
A LOVE STORY IN 3 PARTS


• Writing   Beautiful HTML

• CSS   for fun and profit

• Javascript   like you give a shit Professional Javascript
BEAUTIFUL HTML

• Why?

• Valid

• Semantic

• IDs   vs Classes

• Microformats
Why?
Dr. Strangelove or: How I learned to stop worrying and love HTML, CSS and Javascript
SEMANTIC = MEANINGFUL


• HTML     Elements

• CSS   Classnames and IDs

• Tables   for tables, lists for lists.

• HTML5
IDS AND CLASSES


                                <% div_for photo, :class => "hmedia" do %>
                                    ...
• IDs   are for identification   <% end -%>

                                <div class="photo hmedia" id="photo_1">
• Classes   are categories          . . .
                                </div>
MICROFORMATS


                        <% div_for photo, :class => "hmedia" do %>
• microformats.org      %>
                            <%= content_tag :h2, photo.title, :class => "fn"

                            <a rel="enclosure" type="image/jpeg" href="<%=
                        url_for photo -%>">
• Sensible   Defaults           <%= image_tag "strangelove.jpg", :alt => "Dr.
                        Strangelove", :class => "photo" %>
                            </a>
                            <div class="attribution">
• SpecificHTML with              by <span class="contributor vcard">
                                     <%= link_to photo.user, "http://
 specific classes        example.com", :class => "url fn" %>
                                 </span>
                            </div>
                        <% end -%>
RESOURCEFUL VIEWS


• Self-contained

• Microformatted*

• Matching   our domain
 objects
Cascading Style Sheets
CSS FOR FUN AND PROFIT


• Webkit

• CSS   Frameworks

• Graceful   Degradation/Progressive Enhancement

• CSS   is close enough to OOP
WEBKIT
WEBKIT
WEBKIT



http://www.quirksmode.org/compatibility.html
CSS FRAMEWORKS

       • Sensible
               defaults! DRY!
        Convention over creativity.

       • Resets

       • Clearfix

       • Josef   Muller Brockman
GRACEFUL DEGRADATION
GRACEFUL DEGRADATION
 .editable_tag {
   padding: 5px 10px;
   margin: 5px 10px 0 0;
   background: #bfbfbf; /* lowest common denominator */
   float: left;
   background: -webkit-gradient(linear, left top, left
 bottom, from(#bfbfbf), to(#e4e4e4));
   background: -moz-linear-gradient(top, #bfbfbf, #e4e4e4);
   -webkit-border-radius: 4px; /* Safari 4 */
   -moz-border-radius: 4px; /* Firefox */
   border-radius: 4px; /* Safari 5 & Chrome */
   box-shadow: rgba(0,0,0,1) 0 1px 0;
 }
OBJECT ORIENTED CSS

• CSS
   isn’t that different than
 OOP in other languages        .photo_navigation div.empty_photo{
                                 width: 60px;
                                 height: 60px;
                                 padding: 10px;
• IDs   are singletons           background: silver;
                                 color: white;
                                 font-size: .8em;
• Classes   are Objects        }
                               .photo_navigation
                               img, .photo_navigation
• Inheritance
           and                 div.empty_photo {

 Composition                     float: left;
                                 padding-right: 10px;
                               }

• Namespacing
OBJECT ORIENTED CSS

.photo_navigation div.empty_photo{
  width: 60px;                             class PhotoNavigation::EmptyPhoto
  height: 60px;                                width "60px"
                                               height "60px"
  padding: 10px;
                                               padding "10px"
  background: silver;                      end
  color: white;
  font-size: .8em;                         class PhotoNavigation::OtherOptions
}                                            float "left"
                                             padding_right "10px"
.photo_navigation img, .photo_navigation
                                           end
div.empty_photo {
  float: left;                             empty_photo = PhotoNavigation::EmptyPhoto.new
  margin-right: 10px;                      empty_photo.extend(PhotoNavigation::OtherOptions)
}
PROFESSIONAL JAVASCRIPT


• Build    page to work without Javascript?

• Inline   JS = Legacy code

• Writing    reusable Javascript
WITHOUT JAVASCRIPT?
WITHOUT JAVASCRIPT?



• Do your users turn off
 javascript?
WITHOUT JAVASCRIPT?



• Do your users turn off
 javascript?

• Do   you like testing?
WITHOUT JAVASCRIPT?



• Do your users turn off
 javascript?

• Do   you like testing?
THE CASE FOR UJS

                           <a href="#" onclick="new
                           Ajax.Updater('foo', 'http://
• Very   painful to test   strangelove.local/tags/1',
                           {asynchronous:true,
                           evalScripts:true,
• Impossible   to reuse    parameters:'authenticity_token=' +
                           encodeURIComponent('xXnuBemPMRAar/
• Hard   to debug          EUBB9GbcXD/
                           +HUhOaUxoAnkm5KSy8=')}); return
                           false;">Zip</a>
WRITING REUSABLE
                  JAVASCRIPT
var Photor = {};

Photor.Tags = (function($){

  return {
    init: function(){
                                • Namespaced
      }
 }

})(jQuery);
                                • Public   vs Private Methods
$(document).ready(function(){
  Photor.Tags.init();

});
INIT METHOD
return {
    init: function(){
      $('.edit_tags').live('click', function(event){
        event.preventDefault();
        editTags(event.target);
      });

         $('.destroy_tag').live('click', function(event){
           event.preventDefault();
           removeTag(event.target);
         });

         $('.add_tags').live('submit', function(event){
           event.preventDefault();
           addTags(event.target);
         });

     }
 }
REMOVING A TAG

var removeTag = function(tag){
  var editable_tag = $(tag).closest('.editable_tag');
  $(editable_tag).hide(); //instant user feedback
  $.ajax({url: $(tag).attr('href'),
        type: "POST",
        data: {"_method": 'delete'},
        success: function(data){
          $(editable_tag).remove();
          hideErrors(editable_tag);
        },
        error: function(data){
          $(editable_tag).show();
          handleError(data, editable_tag);
        }
  });
}
SHOWING ADD TAGS

 var editTags = function(target){
   var parent_div = $(target).closest('.tags');
   $('.add_tags', parent_div).show();
   $(target).hide();
 }




//INCORRECT
$('.edit_tags').click(function(event){
  event.preventDefault();
  $('.add_tags').show();
  $(event.target).hide();
});
ADDING TAGS

var addTags = function(form) {
  $.ajax({url: $(form).attr('action') + ".js",
        type: "POST",
        data: $(form).serialize(),
        dataType: "html",
        success: function(data){
           var tags_div = $(form).closest('.tags');
          $('.editable_tag', tags_div).remove();
          $('.error_messages', tags_div).after(data);
          hideErrors();
          $(form).find('input[type=text]').val("");
        },
        error: function(data){
          handleError(data, form);
        }
  });
THINGS TO NOTE


• No   use of “this”

• Not   using IDs

• Closures
         allow for multiples of the same elements to act
 independently
QUESTIONS?


bjclark@scidept.com • http://bjclark.me
Ad

More Related Content

What's hot (20)

Convidar para page !!
Convidar para page !!Convidar para page !!
Convidar para page !!
Jhonny Batista
 
Stack Overflow Austin - jQuery for Developers
Stack Overflow Austin - jQuery for DevelopersStack Overflow Austin - jQuery for Developers
Stack Overflow Austin - jQuery for Developers
Jonathan Sharp
 
Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJS
Aaronius
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript Basics
EPAM Systems
 
jQuery UI and Plugins
jQuery UI and PluginsjQuery UI and Plugins
jQuery UI and Plugins
Marc Grabanski
 
Fcr 2
Fcr 2Fcr 2
Fcr 2
Ravi Peter
 
J Query (Complete Course) by Muhammad Ehtisham Siddiqui
J Query (Complete Course) by Muhammad Ehtisham SiddiquiJ Query (Complete Course) by Muhammad Ehtisham Siddiqui
J Query (Complete Course) by Muhammad Ehtisham Siddiqui
Muhammad Ehtisham Siddiqui
 
webstudy jquery
webstudy jquerywebstudy jquery
webstudy jquery
Seungho Han
 
jQuery (BostonPHP)
jQuery (BostonPHP)jQuery (BostonPHP)
jQuery (BostonPHP)
jeresig
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ Etsy
Nishan Subedi
 
Styling components with JavaScript
Styling components with JavaScriptStyling components with JavaScript
Styling components with JavaScript
bensmithett
 
Jquery 5
Jquery 5Jquery 5
Jquery 5
Manish Kumar Singh
 
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
 
Django Admin: Widgetry & Witchery
Django Admin: Widgetry & WitcheryDjango Admin: Widgetry & Witchery
Django Admin: Widgetry & Witchery
Pamela Fox
 
jQuery (MeshU)
jQuery (MeshU)jQuery (MeshU)
jQuery (MeshU)
jeresig
 
CSS: A Slippery Slope to the Backend
CSS: A Slippery Slope to the BackendCSS: A Slippery Slope to the Backend
CSS: A Slippery Slope to the Backend
FITC
 
jQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and PerformancejQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and Performance
Jonas De Smet
 
jQuery (DrupalCamp Toronto)
jQuery (DrupalCamp Toronto)jQuery (DrupalCamp Toronto)
jQuery (DrupalCamp Toronto)
jeresig
 
Yearning jQuery
Yearning jQueryYearning jQuery
Yearning jQuery
Remy Sharp
 
Fundamental JQuery
Fundamental JQueryFundamental JQuery
Fundamental JQuery
Achmad Solichin
 
Stack Overflow Austin - jQuery for Developers
Stack Overflow Austin - jQuery for DevelopersStack Overflow Austin - jQuery for Developers
Stack Overflow Austin - jQuery for Developers
Jonathan Sharp
 
Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJS
Aaronius
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript Basics
EPAM Systems
 
J Query (Complete Course) by Muhammad Ehtisham Siddiqui
J Query (Complete Course) by Muhammad Ehtisham SiddiquiJ Query (Complete Course) by Muhammad Ehtisham Siddiqui
J Query (Complete Course) by Muhammad Ehtisham Siddiqui
Muhammad Ehtisham Siddiqui
 
jQuery (BostonPHP)
jQuery (BostonPHP)jQuery (BostonPHP)
jQuery (BostonPHP)
jeresig
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ Etsy
Nishan Subedi
 
Styling components with JavaScript
Styling components with JavaScriptStyling components with JavaScript
Styling components with JavaScript
bensmithett
 
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
 
Django Admin: Widgetry & Witchery
Django Admin: Widgetry & WitcheryDjango Admin: Widgetry & Witchery
Django Admin: Widgetry & Witchery
Pamela Fox
 
jQuery (MeshU)
jQuery (MeshU)jQuery (MeshU)
jQuery (MeshU)
jeresig
 
CSS: A Slippery Slope to the Backend
CSS: A Slippery Slope to the BackendCSS: A Slippery Slope to the Backend
CSS: A Slippery Slope to the Backend
FITC
 
jQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and PerformancejQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and Performance
Jonas De Smet
 
jQuery (DrupalCamp Toronto)
jQuery (DrupalCamp Toronto)jQuery (DrupalCamp Toronto)
jQuery (DrupalCamp Toronto)
jeresig
 
Yearning jQuery
Yearning jQueryYearning jQuery
Yearning jQuery
Remy Sharp
 

Viewers also liked (7)

2012-03 Search Congress Community Management Workshop
2012-03 Search Congress Community Management Workshop2012-03 Search Congress Community Management Workshop
2012-03 Search Congress Community Management Workshop
Gillian Muessig
 
Felixlau
FelixlauFelixlau
Felixlau
guestc352eb
 
2011 06 OMS Denver Gillian Muessig - Topic Modeling; Writing for Search Bots ...
2011 06 OMS Denver Gillian Muessig - Topic Modeling; Writing for Search Bots ...2011 06 OMS Denver Gillian Muessig - Topic Modeling; Writing for Search Bots ...
2011 06 OMS Denver Gillian Muessig - Topic Modeling; Writing for Search Bots ...
Gillian Muessig
 
Vocabulary and Cycles
Vocabulary and CyclesVocabulary and Cycles
Vocabulary and Cycles
Pinkham Elementary
 
OOP CSS Presenation
OOP CSS PresenationOOP CSS Presenation
OOP CSS Presenation
RobotDeathSquad
 
ActiveRecord
ActiveRecordActiveRecord
ActiveRecord
RobotDeathSquad
 
Dr. Strangelove: or How I learned to love HTML, CSS, and Javascript
Dr. Strangelove: or How I learned to love HTML, CSS, and JavascriptDr. Strangelove: or How I learned to love HTML, CSS, and Javascript
Dr. Strangelove: or How I learned to love HTML, CSS, and Javascript
RobotDeathSquad
 
2012-03 Search Congress Community Management Workshop
2012-03 Search Congress Community Management Workshop2012-03 Search Congress Community Management Workshop
2012-03 Search Congress Community Management Workshop
Gillian Muessig
 
2011 06 OMS Denver Gillian Muessig - Topic Modeling; Writing for Search Bots ...
2011 06 OMS Denver Gillian Muessig - Topic Modeling; Writing for Search Bots ...2011 06 OMS Denver Gillian Muessig - Topic Modeling; Writing for Search Bots ...
2011 06 OMS Denver Gillian Muessig - Topic Modeling; Writing for Search Bots ...
Gillian Muessig
 
Dr. Strangelove: or How I learned to love HTML, CSS, and Javascript
Dr. Strangelove: or How I learned to love HTML, CSS, and JavascriptDr. Strangelove: or How I learned to love HTML, CSS, and Javascript
Dr. Strangelove: or How I learned to love HTML, CSS, and Javascript
RobotDeathSquad
 
Ad

Similar to Dr. Strangelove or: How I learned to stop worrying and love HTML, CSS and Javascript (20)

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
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011
Chris Alfano
 
How I Learned to Stop Worrying and Love jQuery (Jan 2013)
How I Learned to Stop Worrying and Love jQuery (Jan 2013)How I Learned to Stop Worrying and Love jQuery (Jan 2013)
How I Learned to Stop Worrying and Love jQuery (Jan 2013)
David Giard
 
Awesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescriptAwesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescript
Amir Barylko
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Doris Chen
 
DirectToWeb 2.0
DirectToWeb 2.0DirectToWeb 2.0
DirectToWeb 2.0
WO Community
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
Alive Kuo
 
Unobtrusive JavaScript
Unobtrusive JavaScriptUnobtrusive JavaScript
Unobtrusive JavaScript
Vitaly Baum
 
Using jQuery to Extend CSS
Using jQuery to Extend CSSUsing jQuery to Extend CSS
Using jQuery to Extend CSS
Chris Coyier
 
Big Data for each one of us
Big Data for each one of usBig Data for each one of us
Big Data for each one of us
OSCON Byrum
 
J query
J queryJ query
J query
Manav Prasad
 
Evrone.ru / BEM for RoR
Evrone.ru / BEM for RoREvrone.ru / BEM for RoR
Evrone.ru / BEM for RoR
Dmitry KODer
 
Jquery In Rails
Jquery In RailsJquery In Rails
Jquery In Rails
shen liu
 
建立前端開發團隊 - 2011 中華電信訓練所版
建立前端開發團隊 - 2011 中華電信訓練所版建立前端開發團隊 - 2011 中華電信訓練所版
建立前端開發團隊 - 2011 中華電信訓練所版
Joseph Chiang
 
前端MVC之BackboneJS
前端MVC之BackboneJS前端MVC之BackboneJS
前端MVC之BackboneJS
Zhang Xiaoxue
 
CSS3 Takes on the World
CSS3 Takes on the WorldCSS3 Takes on the World
CSS3 Takes on the World
Jonathan Snook
 
Styling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS EditionStyling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS Edition
bensmithett
 
Bcblackpool jquery tips
Bcblackpool jquery tipsBcblackpool jquery tips
Bcblackpool jquery tips
Jack Franklin
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
Richard Leland
 
Html standards presentation
Html standards presentationHtml standards presentation
Html standards presentation
Tiago Cardoso
 
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
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011
Chris Alfano
 
How I Learned to Stop Worrying and Love jQuery (Jan 2013)
How I Learned to Stop Worrying and Love jQuery (Jan 2013)How I Learned to Stop Worrying and Love jQuery (Jan 2013)
How I Learned to Stop Worrying and Love jQuery (Jan 2013)
David Giard
 
Awesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescriptAwesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescript
Amir Barylko
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Doris Chen
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
Alive Kuo
 
Unobtrusive JavaScript
Unobtrusive JavaScriptUnobtrusive JavaScript
Unobtrusive JavaScript
Vitaly Baum
 
Using jQuery to Extend CSS
Using jQuery to Extend CSSUsing jQuery to Extend CSS
Using jQuery to Extend CSS
Chris Coyier
 
Big Data for each one of us
Big Data for each one of usBig Data for each one of us
Big Data for each one of us
OSCON Byrum
 
Evrone.ru / BEM for RoR
Evrone.ru / BEM for RoREvrone.ru / BEM for RoR
Evrone.ru / BEM for RoR
Dmitry KODer
 
Jquery In Rails
Jquery In RailsJquery In Rails
Jquery In Rails
shen liu
 
建立前端開發團隊 - 2011 中華電信訓練所版
建立前端開發團隊 - 2011 中華電信訓練所版建立前端開發團隊 - 2011 中華電信訓練所版
建立前端開發團隊 - 2011 中華電信訓練所版
Joseph Chiang
 
前端MVC之BackboneJS
前端MVC之BackboneJS前端MVC之BackboneJS
前端MVC之BackboneJS
Zhang Xiaoxue
 
CSS3 Takes on the World
CSS3 Takes on the WorldCSS3 Takes on the World
CSS3 Takes on the World
Jonathan Snook
 
Styling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS EditionStyling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS Edition
bensmithett
 
Bcblackpool jquery tips
Bcblackpool jquery tipsBcblackpool jquery tips
Bcblackpool jquery tips
Jack Franklin
 
Html standards presentation
Html standards presentationHtml standards presentation
Html standards presentation
Tiago Cardoso
 
Ad

Recently uploaded (20)

Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Raffi Khatchadourian
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Play It Safe: Manage Security Risks - Google Certificate
Play It Safe: Manage Security Risks - Google CertificatePlay It Safe: Manage Security Risks - Google Certificate
Play It Safe: Manage Security Risks - Google Certificate
VICTOR MAESTRE RAMIREZ
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Connect and Protect: Networks and Network Security
Connect and Protect: Networks and Network SecurityConnect and Protect: Networks and Network Security
Connect and Protect: Networks and Network Security
VICTOR MAESTRE RAMIREZ
 
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Raffi Khatchadourian
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
The Changing Compliance Landscape in 2025.pdf
The Changing Compliance Landscape in 2025.pdfThe Changing Compliance Landscape in 2025.pdf
The Changing Compliance Landscape in 2025.pdf
Precisely
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
TrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI PaymentsTrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI Payments
Trs Labs
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
Transcript: Canadian book publishing: Insights from the latest salary survey ...
Transcript: Canadian book publishing: Insights from the latest salary survey ...Transcript: Canadian book publishing: Insights from the latest salary survey ...
Transcript: Canadian book publishing: Insights from the latest salary survey ...
BookNet Canada
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Raffi Khatchadourian
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Play It Safe: Manage Security Risks - Google Certificate
Play It Safe: Manage Security Risks - Google CertificatePlay It Safe: Manage Security Risks - Google Certificate
Play It Safe: Manage Security Risks - Google Certificate
VICTOR MAESTRE RAMIREZ
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Connect and Protect: Networks and Network Security
Connect and Protect: Networks and Network SecurityConnect and Protect: Networks and Network Security
Connect and Protect: Networks and Network Security
VICTOR MAESTRE RAMIREZ
 
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Raffi Khatchadourian
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
The Changing Compliance Landscape in 2025.pdf
The Changing Compliance Landscape in 2025.pdfThe Changing Compliance Landscape in 2025.pdf
The Changing Compliance Landscape in 2025.pdf
Precisely
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
TrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI PaymentsTrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI Payments
Trs Labs
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
Transcript: Canadian book publishing: Insights from the latest salary survey ...
Transcript: Canadian book publishing: Insights from the latest salary survey ...Transcript: Canadian book publishing: Insights from the latest salary survey ...
Transcript: Canadian book publishing: Insights from the latest salary survey ...
BookNet Canada
 

Dr. Strangelove or: How I learned to stop worrying and love HTML, CSS and Javascript

  • 1. DR. STRANGELOVE OR: HOW I LEARNED TO STOP WORRYING AND LOVE HTML, CSS, AND JAVASCRIPT
  • 2. BJ CLARK UX Developer @ http://goldstar.com @RobotDeathSquad http://github.com/BJClark http://bjclark.me
  • 6. A LOVE STORY IN 3 PARTS • Writing Beautiful HTML • CSS for fun and profit • Javascript like you give a shit Professional Javascript
  • 7. BEAUTIFUL HTML • Why? • Valid • Semantic • IDs vs Classes • Microformats
  • 10. SEMANTIC = MEANINGFUL • HTML Elements • CSS Classnames and IDs • Tables for tables, lists for lists. • HTML5
  • 11. IDS AND CLASSES <% div_for photo, :class => "hmedia" do %> ... • IDs are for identification <% end -%> <div class="photo hmedia" id="photo_1"> • Classes are categories . . . </div>
  • 12. MICROFORMATS <% div_for photo, :class => "hmedia" do %> • microformats.org %> <%= content_tag :h2, photo.title, :class => "fn" <a rel="enclosure" type="image/jpeg" href="<%= url_for photo -%>"> • Sensible Defaults <%= image_tag "strangelove.jpg", :alt => "Dr. Strangelove", :class => "photo" %> </a> <div class="attribution"> • SpecificHTML with by <span class="contributor vcard"> <%= link_to photo.user, "http:// specific classes example.com", :class => "url fn" %> </span> </div> <% end -%>
  • 13. RESOURCEFUL VIEWS • Self-contained • Microformatted* • Matching our domain objects
  • 15. CSS FOR FUN AND PROFIT • Webkit • CSS Frameworks • Graceful Degradation/Progressive Enhancement • CSS is close enough to OOP
  • 19. CSS FRAMEWORKS • Sensible defaults! DRY! Convention over creativity. • Resets • Clearfix • Josef Muller Brockman
  • 21. GRACEFUL DEGRADATION .editable_tag { padding: 5px 10px; margin: 5px 10px 0 0; background: #bfbfbf; /* lowest common denominator */ float: left; background: -webkit-gradient(linear, left top, left bottom, from(#bfbfbf), to(#e4e4e4)); background: -moz-linear-gradient(top, #bfbfbf, #e4e4e4); -webkit-border-radius: 4px; /* Safari 4 */ -moz-border-radius: 4px; /* Firefox */ border-radius: 4px; /* Safari 5 & Chrome */ box-shadow: rgba(0,0,0,1) 0 1px 0; }
  • 22. OBJECT ORIENTED CSS • CSS isn’t that different than OOP in other languages .photo_navigation div.empty_photo{ width: 60px; height: 60px; padding: 10px; • IDs are singletons background: silver; color: white; font-size: .8em; • Classes are Objects } .photo_navigation img, .photo_navigation • Inheritance and div.empty_photo { Composition float: left; padding-right: 10px; } • Namespacing
  • 23. OBJECT ORIENTED CSS .photo_navigation div.empty_photo{ width: 60px; class PhotoNavigation::EmptyPhoto height: 60px; width "60px" height "60px" padding: 10px; padding "10px" background: silver; end color: white; font-size: .8em; class PhotoNavigation::OtherOptions } float "left" padding_right "10px" .photo_navigation img, .photo_navigation end div.empty_photo { float: left; empty_photo = PhotoNavigation::EmptyPhoto.new margin-right: 10px; empty_photo.extend(PhotoNavigation::OtherOptions) }
  • 24. PROFESSIONAL JAVASCRIPT • Build page to work without Javascript? • Inline JS = Legacy code • Writing reusable Javascript
  • 26. WITHOUT JAVASCRIPT? • Do your users turn off javascript?
  • 27. WITHOUT JAVASCRIPT? • Do your users turn off javascript? • Do you like testing?
  • 28. WITHOUT JAVASCRIPT? • Do your users turn off javascript? • Do you like testing?
  • 29. THE CASE FOR UJS <a href="#" onclick="new Ajax.Updater('foo', 'http:// • Very painful to test strangelove.local/tags/1', {asynchronous:true, evalScripts:true, • Impossible to reuse parameters:'authenticity_token=' + encodeURIComponent('xXnuBemPMRAar/ • Hard to debug EUBB9GbcXD/ +HUhOaUxoAnkm5KSy8=')}); return false;">Zip</a>
  • 30. WRITING REUSABLE JAVASCRIPT var Photor = {}; Photor.Tags = (function($){ return { init: function(){ • Namespaced } } })(jQuery); • Public vs Private Methods $(document).ready(function(){ Photor.Tags.init(); });
  • 31. INIT METHOD return { init: function(){ $('.edit_tags').live('click', function(event){ event.preventDefault(); editTags(event.target); }); $('.destroy_tag').live('click', function(event){ event.preventDefault(); removeTag(event.target); }); $('.add_tags').live('submit', function(event){ event.preventDefault(); addTags(event.target); }); } }
  • 32. REMOVING A TAG var removeTag = function(tag){ var editable_tag = $(tag).closest('.editable_tag'); $(editable_tag).hide(); //instant user feedback $.ajax({url: $(tag).attr('href'), type: "POST", data: {"_method": 'delete'}, success: function(data){ $(editable_tag).remove(); hideErrors(editable_tag); }, error: function(data){ $(editable_tag).show(); handleError(data, editable_tag); } }); }
  • 33. SHOWING ADD TAGS var editTags = function(target){ var parent_div = $(target).closest('.tags'); $('.add_tags', parent_div).show(); $(target).hide(); } //INCORRECT $('.edit_tags').click(function(event){ event.preventDefault(); $('.add_tags').show(); $(event.target).hide(); });
  • 34. ADDING TAGS var addTags = function(form) { $.ajax({url: $(form).attr('action') + ".js", type: "POST", data: $(form).serialize(), dataType: "html", success: function(data){ var tags_div = $(form).closest('.tags'); $('.editable_tag', tags_div).remove(); $('.error_messages', tags_div).after(data); hideErrors(); $(form).find('input[type=text]').val(""); }, error: function(data){ handleError(data, form); } });
  • 35. THINGS TO NOTE • No use of “this” • Not using IDs • Closures allow for multiples of the same elements to act independently