Skip to content

Commit b930e7c

Browse files
committed
Removed needless DOM query
cached body element in local variable to avoid multiple DOM queries on the same element
1 parent b45ce0e commit b930e7c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

source/javascripts/main.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
(function(){
66
'use strict';
7+
8+
var body = document.querySelector('body');
79

810
Lib.ready(function() {
911
/* jshint -W031 */
@@ -22,11 +24,11 @@
2224
]);
2325

2426
document.querySelector('#switch-dark').addEventListener('click', function() {
25-
document.querySelector('body').className = 'index black';
27+
body.className = 'index black';
2628
});
2729

2830
document.querySelector('#switch-light').addEventListener('click', function() {
29-
document.querySelector('body').className = 'index white';
31+
body.className = 'index white';
3032
});
3133
});
3234
})();

0 commit comments

Comments
 (0)