Created
January 20, 2018 15:25
-
-
Save gorhill/365cfec0af9219d0168f1ab9388b01e1 to your computer and use it in GitHub Desktop.
Using MutationObserver on http://browserbench.org/Speedometer/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var addedNodesCount = 0; | |
var removedNodesCount = 0; | |
var observer = new MutationObserver(function(mutations) { | |
var i = mutations.length; | |
while ( i-- ) { | |
var mutation = mutations[i]; | |
addedNodesCount += mutation.addedNodes.length; | |
removedNodesCount += mutation.removedNodes.length; | |
} | |
console.log('addedNodesCount=' + addedNodesCount, 'removedNodesCount=' + removedNodesCount); | |
}); | |
observer.observe(document.documentElement, { | |
childList: true, | |
subtree: true | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
content.js:10 addedNodesCount=76 | |
content.js:10 addedNodesCount=78 | |
content.js:10 addedNodesCount=88 | |
content.js:10 addedNodesCount=658 removedNodesCount=516 | |
content.js:10 addedNodesCount=10590 | |
content.js:10 addedNodesCount=659 removedNodesCount=517 | |
content.js:10 addedNodesCount=31190 | |
content.js:10 addedNodesCount=660 removedNodesCount=518 | |
content.js:10 addedNodesCount=31194 | |
content.js:10 addedNodesCount=661 removedNodesCount=519 | |
content.js:10 addedNodesCount=120 | |
content.js:10 addedNodesCount=121 | |
content.js:10 addedNodesCount=123 | |
content.js:10 addedNodesCount=124 | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"manifest_version": 2, | |
"name": "webext-mutation-observer", | |
"version": "1.0", | |
"content_scripts": [ | |
{ | |
"matches": ["http://browserbench.org/*"], | |
"js": ["content.js"], | |
"run_at": "document_start", | |
"all_frames": true | |
} | |
], | |
"permissions": [ | |
"http://browserbench.org/*" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment