Weitere ähnliche Inhalte
Ähnlich wie bsSelector (GDG DevFest 2014) (20)
bsSelector (GDG DevFest 2014)
- 7. bsJS
var color = $('#domID').css( {
'borderRadius' : 5,
‘color’ : ‘#fff’
} )
.attr('width', 100)
.click(function(){alert(1)})
.css('color');
console.log(color) // "#fff"
- 8. bsJS
var color = $('#domID').css( {
'borderRadius' : 5,
‘color’ : ‘#fff’
} )
.attr('width', 100)
.click(function(){alert(1)})
.css('color');
console.log(color) // "#fff"
var color = bs.Dom('#domID')
.S('border-radius', 5,
'@width', 100,
‘click’, function(){alert(1)},
’color', '#fff');
console.log(color) // "#fff"
- 9. bsJS
var color = $('#domID').css( {
'borderRadius' : 5,
‘color’ : ‘#fff’
} )
.attr('width', 100)
.click(function(){alert(1)})
.css('color');
console.log(color) // "#fff"
var color = bs.Dom('#domID')
.S('border-radius', 5,
'@width', 100,
‘click’, function(){alert(1)},
’color', '#fff');
console.log(color) // "#fff"
호스트코드: 110 byte
오브젝트 생성: O
함수호출: 4회
호스트코드: 94 byte
오브젝트 생성: X
함수호출: 1회
- 24. query = 'ul.toc li.tocline2‘;
tokens = ['ul', '.toc', ' ', 'li', ‘.tocline2‘];
if(tokens[i].charAt(0) == '#')
document.getElementById(tokens[i].substr(1));
else if(tokens[i].charAt(0) == '.')
document.getElementByClassName(tokens[i].substr(1));
else
document.getElementsByTagName('*');
- 42. ID TAG CLASS NAME
2,096,567 1,876,875 1,841,273 1,575,123
17,090,351 8,920,145 8,285,463 8,031,034
19,384,745 16,661,973 17,559,678 19,073,485
- 44. ID TAG CLASS
124,963 126,480 106,504
1,091,549 222,199 210,918
2,020,367 321,119 339,747
- 58. 함수 호출을 최소화 한다
function Non function
16,830 54,080
49,063 49,436
51,524 52,066
- 61. var els = document.getElementsByTagName(‘div’);
Console.log(els.length); // 1
var newEl = document.createElement(‘div’);
document.body.appendChild(newEl);
console.log(els.length); // 2
Hinweis der Redaktion
- http://jsperf.com/jsconf-id-class-name-tag
- http://jsperf.com/jsconf-id-class-name-tag/2
- http://jsperf.com/jsconf-function-vs-non-function