
The act of performing; carrying into execution or action; execution; achievement; accomplishment; representation by action; as, the performance of an undertaking of a duty.
Doing something that has a result.
var doingSomething = 'Displaying a web page';
var result = 'speed';
var performance = doingSomething + ' with _adjective_' + result;
function performanceDefinition(adjective) {
console.log(
performance.replace(/_adjective_/g, adjective ? adjective + ' ' : '')
);
}
performanceDefinition();
// > "Displaying a web page with speed"
var i, il;
var types = [
'awesome', 'good', 'bad', 'terrible'
];
for (i = 0, il = types.length; i < il; i++) {
performanceDefinition(types[i]);
}
// > "Displaying a web page with awesome speed"
// > "Displaying a web page with good speed"
// > "Displaying a web page with bad speed"
// > "Displaying a web page with terrible speed"
position: static
position: relative
float: left/right
)position: absolute
position: fixed
position:relative
if you don't need todiv { position: relative; } .moveable_class { position: absolute; !important }
<div>Hello</div> <div>world!</div> <div>How are you today?</div> <div> <div class="moveable_class" style="left: 34px; top: 50px">Dandy</div> </div> <div>:)</div>
function HTMLHtmlElement() { Object.defineProperty(this, 'offsetWidth', { get: function() { // Calculate all child elements' positions and sizes! }, configurable: false, enumerable: true }); } var element = new HTMLHtmlElement(); for (var i = 0; i < 10000; i++) { console.log(element.offsetWidth) }
Which of the above properties cause a lot of calculations do happen in the background?
http://www.w3.org/TR/cssom-view/All of them
These properties all calculate their own size (padding edge or border edge).
All of their children's sizes are also be calculated.
var element, body = document.body; for (var i = 0; i < 500; i++) { element = document.createElement('div'); body.appendChild(element); element.style.width = element.style.height = '40px'; }
var element, body = document.body; var fragment = document.createDocumentFragment(); for (var i = 0; i < 500; i++) { element = document.createElement('div'); element.style.width = element.style.height = '40px'; fragment.appendChild(element); } body.appendChild(fragment);
There are many articles on the Internet saying that it is faster to remove the group of nodes you are about to edit from the DOM tree (removeChild), edit all the nodes (avoiding reflow), and re-insert them back in to the same place in the DOM tree.
Let's see what happens when we try out the Remove/Re-add Rule!
The Remove/Re-add Rule and GPU mode with transform: translate3d
instead of left and top!
Without the Remove/Re-add Rule with translate3d!
Use fillStyle and bezierCurveTo each frame to draw all 500 hearts
Cache all 500 hearts as individual Canvases and drawImage them
Contact Information