Como Perder Peso (no browser)

Como Perder Peso (no browser)

Presented at Rio.JS Conf
March 9, 2013
Rio de Janeiro, Brazil

Zeno Rocha

March 09, 2013

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

149 slides
  1. “Otimize a performance do front-end primeiro, é onde 80/90% do

    tempo de resposta ao usuário é gasto.” - Steve Souders
  2. • Economizar 1kb significa: • Em 60 segundos = 3.4GB

    Fonte: http://jaydson.org/talks/x-web-performance/
  3. • Economizar 1kb significa: • Em 1 hora = 180GB

    Fonte: http://jaydson.org/talks/x-web-performance/
  4. • Economizar 1kb significa: • Em 1 dia = 4.2TB

    Fonte: http://jaydson.org/talks/x-web-performance/
  5. • + 15.000.000 de acessos por dia • De 3mb

    para 267kb • De 7.5s para 4.3s Fonte: http://www.slideshare.net/keppelen/performance-frontend-front-in-macei/
  6. • Diminuir 3.2s resultou em: • Redução de custo em

    servidores de R$ 16.000,00 por dia Fonte: http://www.slideshare.net/keppelen/performance-frontend-front-in-macei/
  7. • Diminuir 3.2s resultou em: • Aumento de receita de

    R$ 1.000.000,00 por dia Fonte: http://www.slideshare.net/keppelen/performance-frontend-front-in-macei/
  8. #26 <body> <p>Lorem ipsum dolor sit amet.</p> <!-- JS -->

    <script src="script.js"></script> </body> </html>
  9. normal #25 <p>Lorem ipsum dolor sit amet.</p> <!-- My List

    --> <ul> <li><a href="#"></a></li> <li><a href="#"></a></li> <li><a href="#"></a></li> </ul>
  10. CSS

  11. normal #23 .center { width: 960px; margin: 0 auto; }

    /* --- Structure --- */ .intro { margin: 100px; }
  12. #22 <link rel="stylesheet" href="structure.css"> <link rel="stylesheet" href="banner.css"> <link rel="stylesheet" href="layout.css">

    <link rel="stylesheet" href="component.css"> <link rel="stylesheet" href="all.css"> vs
  13. key selector header nav ul li * { /* Péssimo

    */ } header nav ul li a { /* Muito Ruim */ } nav a { /* Ruim */ } nav a.nav-link { /* Bom */ } nav .nav-link { /* Ótimo */ } .nav-link { /* Excelente */ } #19
  14. ruim... var arr = new Array(1000); for (var i =

    0; i < arr.length; i++) { // O tamanho do array é calculado 1000 } #17
  15. bom! var arr = new Array(1000); for (var i =

    0, len = arr.length; i < len; i++) { // O tamanho só é calculado 1 vez e armazenado } #17
  16. ruim... var myList = document.getElementById("myList"); for (var i = 0;

    i < 100; i++) { myList.innerHTML += "<span>" + i + "</span>"; } #15
  17. var myList = ""; for (var i = 0; i

    < 100; i++) { myList += "<span>" + i + "</span>"; } document.getElementById("myList").innerHTML = myList; bom! #15
  18. normal #14 BrowserDiet.app = function() { var foo = true;

    return { bar: function() { // do something } }; };
  19. #9 for ( var i = 0, len = a.length;

    i < len; i++ ) { e = a[i]; } for é mais rapido
  20. css #7 .icon-foo { background-image: url('mySprite.png'); background-position: -10px -10px; }

    .icon-bar { background-image: url('mySprite.png'); background-position: -5px -5px; }
  21. .htaccess #4 ExpiresActive On ExpiresByType image/gif "access plus 6 months"

    ExpiresByType image/jpeg "access plus 6 months" ExpiresByType image/png "access plus 6 months" ExpiresByType text/css "access plus 6 months" ExpiresByType text/javascript "access plus 6 months"
  22. .htaccess #3 AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE

    text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/javascript

More Decks by Zeno Rocha

Other Decks in Technology