Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Perfecting eCommerce Frontend

Perfecting eCommerce Frontend

Frontend performance talk for SpreeConf 2013, with slight eCommerce inclination.

jumph4x

May 20, 2013
Tweet

Other Decks in Programming

Transcript

  1. I'm Denis, I like performance I'm Denis, I like performance

    I'm actually moving, swear I'm actually moving, swear ↑ ↑
  2. http://www.stevesouders.com/blog/2012/02/10/the-performance-golden-rule/ 80-90% of the end- 80-90% of the end- user

    response time is user response time is spent on the frontend. spent on the frontend. Start there.” Start there.” “ “ Steve Souders Steve Souders
  3. The full webpage path The full webpage path Draw @

    ~350 ms Draw @ ~350 ms Done @ ~740 ms Done @ ~740 ms
  4. Excellent! Excellent! IDs: IDs: #unique #unique Classes: Classes: .reusable .reusable

    http://csswizardry.com/2011/09/writing-efficient-css-selectors/
  5. Good Good Tags: Tags: element element Siblings: Siblings: el +

    ements el + ements Children: Children: el > ements el > ements Descendants: Descendants: el ements el ements http://csswizardry.com/2011/09/writing-efficient-css-selectors/
  6. Slow! Slow! Universal: Universal: * * Attribute: Attribute: [type='text'] [type='text']

    Pseudo: Pseudo: :nth-child() :nth-child() http://csswizardry.com/2011/09/writing-efficient-css-selectors/ Regex?! Regex?! [class^='icon'] [class^='icon']
  7. The The original original responsive: responsive: time to begin time

    to begin render render http://www.stevesouders.com/blog/2013/04/26/i/
  8. <html> <html> <head> <head> <link rel=' <link rel='stylesheet stylesheet' …

    ' … <link rel='all-else' /> <link rel='all-else' /> < <script script async=”async” async=”async” /> /> </head> </head>
  9. // Sass/Scss/CSS // Sass/Scss/CSS @import "variables" @import "variables" @import "header"

    @import "header" ... ... @import @import */ JS/Coffee /* */ JS/Coffee /* //= require ./one //= require ./one //= require ./two //= require ./two
  10. # config/environments/production.rb # config/environments/production.rb config.asset_host = Proc.new { |*args| config.asset_host

    = Proc.new { |*args| source, request = args source, request = args images = source && source.match(/products/) images = source && source.match(/products/) no_ssl = request && !request.ssl? no_ssl = request && !request.ssl? if no_ssl && images if no_ssl && images "//assets#{rand(5)}.fcpstores.com" "//assets#{rand(5)}.fcpstores.com" else else "//123456abcde.cloudfront.net" "//123456abcde.cloudfront.net" end end } } $$$ HUGE $$$ HUGE
  11. http://guides.rubyonrails.org/3_1_release_notes.html#http-streaming def action def action @collection = Model.gimme.all @collection =

    Model.gimme.all respond_to do |format| respond_to do |format| format.html format.html end end end end
  12. # app/controllers/my_objeckz.rb # app/controllers/my_objeckz.rb def action def action - -

    @collection = Objekt.gimme.all @collection = Objekt.gimme.all respond_to do |format| respond_to do |format| - format.html - format.html + format.html{ render :action, :streaming => true } + format.html{ render :action, :streaming => true } end end end end + helper_method :collection + helper_method :collection + def collection + def collection + @collection ||= Objekt.gimme.all + @collection ||= Objekt.gimme.all + end + end http://weblog.rubyonrails.org/2011/4/18/why-http-streaming/
  13. Browser hints Browser hints <link rel=" <link rel="dns-prefetch dns-prefetch" "

    href=" href="//mysite.cloudfront.com //mysite.cloudfront.com "> "> <link rel=" <link rel="prefetch prefetch" href=" " href="/next-step.html /next-step.html"> "> <link rel=" <link rel="prefetch prefetch" href=" " href="large-image.png large-image.png"> "> <link rel=" <link rel="subresource subresource" href=" " href="end-of- end-of- document.js document.js"> ">
  14. Fire your SEO firm Fire your SEO firm Start reading

    Start reading Webmaster Academy Webmaster Academy http://support.google.com/webmasters/bin/static.py?hl=en&page=checklist.cs&tab=1095542 (ProTip) (ProTip)
  15. Dec 2011 Dec 2011 May 2013 May 2013 Daily organic

    visits Daily organic visits 4000 4000
  16. www.fcpeuro.com/BMW-parts/325i/Suspension/ www.fcpeuro.com/BMW-parts/325i/Suspension/?year=1993 ?year=1993 www.fcpeuro.com/BMW-parts/325i/ www.fcpeuro.com/BMW-parts/325i/Suspension/ Suspension/ www.fcpeuro.com/BMW-parts/ www.fcpeuro.com/BMW-parts/325i/ 325i/ www.fcpeuro.com/

    www.fcpeuro.com/BMW-parts/ BMW-parts/ www.fcpeuro.com/ www.fcpeuro.com/ www.fcpeuro.com/ www.fcpeuro.com/about-us about-us Trimmable URLs Trimmable URLs http://support.google.com/webmasters/bin/answer.py?hl=en&answer=76329 http://googlewebmastercentral.blogspot.com/2010/04/to-slash-or-not-to-slash.html
  17. Regex Constraints Regex Constraints # config/routes.rb # config/routes.rb MAKES =

    /BMW|Saab/ MAKES = /BMW|Saab/ MODELS = /325i/900/ MODELS = /325i/900/ match '( match '(:make :make)-parts/ )-parts/:model :model' => 'spree/products#index', ' => 'spree/products#index', :via => :get, :via => :get, :trailing_slash => true, :trailing_slash => true, :make :make => MAKES, => MAKES, :model :model => MODELS => MODELS match '( match '(:make :make)-parts(/ )-parts(/:taxon :taxon)' => "spree/products#index", )' => "spree/products#index", :via => :get, :via => :get, :trailing_slash => true, :trailing_slash => true, :make :make => MAKES => MAKES www.fcpeuro.com/ www.fcpeuro.com/BMW BMW-parts/ -parts/325i 325i/ / www.fcpeuro.com/ www.fcpeuro.com/BMW BMW-parts/ -parts/SomeTaxonName SomeTaxonName/ /
  18. CanonicalRails CanonicalRails https://github.com/jumph4x/canonical-rails A lot of folks do harm by

    A lot of folks do harm by neglecting canonicalization neglecting canonicalization [...], here is a [library] to start [...], here is a [library] to start on it...” on it...” “ “
  19. Authoritative version Authoritative version http://mystore.com/shoes http://mystore.com/shoes http://mystore.com/shoes http://mystore.com/shoes / /

    http:// http://www. www.mystore.com/shoes mystore.com/shoes http://mystore.com/products? http://mystore.com/products? taxon_permalink taxon_permalink =shoes =shoes http://mystore.com/products? http://mystore.com/products? sort sort=price =price http://mystore.com/products? http://mystore.com/products? doesnt_exist doesnt_exist=true =true http://mystore.com/products? http://mystore.com/products? keyword_attack keyword_attack= =viagra viagra http://support.google.com/webmasters/bin/answer.py?hl=en&answer=139394
  20. rel='canonical' rel='canonical' # config/initializers/canonical_rails.rb # config/initializers/canonical_rails.rb CanonicalRails.setup do |config| CanonicalRails.setup

    do |config| config.host = ' config.host = 'www.mywebstore.com www.mywebstore.com' ' config.collection_actions = [ config.collection_actions = [:index, :available :index, :available] ] config.whitelisted_parameters = [ config.whitelisted_parameters = [:country :country] ] end end <html> <html> <head> <head> <%= <%= canonical_tag canonical_tag -%> -%> ... ... </head> </head> ... ...
  21. <div <div itemscope itemtype=" itemscope itemtype=" http://schema.org/Product http://schema.org/Product" "> >

    <img <img itemprop=" itemprop="image image" " src="dell-30in-lcd.jpg" /> src="dell-30in-lcd.jpg" /> <span <span itemprop=" itemprop="name name" ">Dell UltraSharp 30" LCD >Dell UltraSharp 30" LCD Monitor</span> Monitor</span> <div <div itemprop=" itemprop="aggregateRating aggregateRating" " itemscope itemtype=" itemscope itemtype="http://schema.org/AggregateRating http://schema.org/AggregateRating " "> > <span <span itemprop=" itemprop="ratingValue ratingValue" ">87</span> >87</span> out of <span out of <span itemprop=" itemprop="bestRating bestRating" ">100</span> >100</span> based on <span based on <span itemprop=" itemprop="ratingCount ratingCount" ">24</span> user >24</span> user ratings ratings </div> </div>
  22. Content Pages Content Pages home#index home#index products#index products#index products#index' products#index'

    products#index'' products#index'' products#index''' products#index''' products#show products#show orders#edit orders#edit [...] [...] home#index home#index products#index products#index products#index' products#index' products#index'' products#index'' products#index''' products#index''' products#show products#show orders#edit orders#edit [...] [...] Brand, value prop Brand, value prop Best sellers? Best sellers? Broad category Broad category Specific category Specific category Longtail category Longtail category Details, how-tos Details, how-tos Brand, value prop Brand, value prop Best sellers? Best sellers? Broad category Broad category Specific category Specific category Longtail category Longtail category Details, how-tos Details, how-tos Specificity Gradient Specificity Gradient Specificity Gradient Specificity Gradient
  23. Start at the bottom Start at the bottom Start at

    the bottom Start at the bottom Product Detail Product Detail Product Detail Product Detail