On Github ggarnier / resumo-velocityconf-ny-2014
1 dia de tutoriais
2 dias de palestras
muitos temas repetidos
poucas palestras se aprofundaram em algum tema
Fonte: Jakob Nielsen
[1] http://gizmodo.com/5982677/a-facebook-bug-pretty-much-took-down-the-entire-internet
Carregamento assíncrono
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) { return; }
js = d.createElement(s); js.id = id;
js.src = "//cdn.example.com/script.js";
fjs.parentNode.insertBefore(js, fjs);
})(document, 'script', 'vf-js');
ou, nos browsers mais modernos:
<script async defer src="//cdn.example.com/script.js" />
Ex: jQuery da CDN do Google
var sNew = document.createElement("script");
sNew.async = true;
sNew.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js";
var s0 = document.getElementsByTagName('script')[0];
s0.parentNode.insertBefore(sNew, s0);
window.jQuery ||
document.write('<script src="/path/to/your/jquery" />');
.thumb {
width: 180px;
height: 108px;
}
@media (max-width: 978px) and (min-width: 711px) {
.thumb {
width: 134px;
height: 80px;
}
}
@media (max-width: 710px) {
.thumb {
width: 140px;
height: 84px;
}
}
window.performance.timing;
{
connectEnd: 1412379511942,
connectStart: 1412379511010,
domComplete: 1412379514540,
domContentLoadedEventEnd: 1412379514254,
domContentLoadedEventStart: 1412379514243,
...
}
Tempo total para carregar a página:
var perfData = window.performance.timing; perfData.loadEventEnd - perfData.navigationStart;
Tempo de resposta de um request:
var perfData = window.performance.timing; perfData.responseEnd - perfData.requestStart;
window.performance.getEntriesByType('resource');
[{
entryType: "resource",
initiatorType: "script",
name: "http://www.google-analytics.com/analytics.js",
duration: 16.396000050008297,
startTime: 1242.3169999965467,
redirectStart: 0,
redirectEnd: 0,
fetchStart: 1242.3169999965467,
connectStart: 0,
connectEnd: 0,
responseStart: 0,
responseEnd: 1258.713000046555,
...
}, ...
]
http://www.sitepoint.com/discovering-user-timing-api/ http://www.w3.org/TR/user-timing/
Instrumentação de operações sob demanda
// Marca o início de uma operação
window.performance.mark("startOperation");
doSomethingSlow();
// Marca o fim da operação
window.performance.mark("endOperation");
// Calcula as medições
window.performance.measure("slowOperation", "startOperation", "endOperation");
window.performance.getEntriesByName("slowOperation");
// ou window.performance.getEntriesByType("measure");
[{
duration: 7444.391000026371,
entryType: "measure",
name: "slowOperation",
startTime: 191147.77599996887
}, ...]
// Remove todas as marcações
window.performance.clearMarks();
// Remove a medição "slowOperation"
window.performance.clearMeasure("slowOperation");
carregar o código num iframe
http://velocityconf.com/velocityny2014
https://www.youtube.com/playlist?list=PL055Epbe6d5YDU6sikjqcd_YM9XT4OehD