Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion script/analyseFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

function countShadom() {
const countElements = (element) => {
let count = 1;
Array.from(element.children).forEach(child => {
count += countElements(child);
});

if (element.shadowRoot) {
Array.from(element.shadowRoot.children).forEach(sChild => {
count += countElements(sChild);
});
}
return count;
};

return countElements(document.body)
}

function start_analyse() {
const analyseStartingTime = Date.now();
const dom_size = getDomSizeWithoutSvg();
Expand All @@ -28,7 +46,7 @@ function start_analyse() {
}

function getDomSizeWithoutSvg(){
let dom_size = document.getElementsByTagName("*").length;
let dom_size = countShadom();
const svgElements = document.getElementsByTagName("svg");
for (let i = 0 ; i< svgElements.length ; i++) {
dom_size -= getNbChildsExcludingNestedSvg(svgElements[i])-1;
Expand Down
20 changes: 19 additions & 1 deletion script/analyseFrameWithBestPractices.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

function countShadom() {
const countElements = (element) => {
let count = 1;
Array.from(element.children).forEach(child => {
count += countElements(child);
});

if (element.shadowRoot) {
Array.from(element.shadowRoot.children).forEach(sChild => {
count += countElements(sChild);
});
}
return count;
};

return countElements(document.body)
}

function start_analyse() {
const analyseStartingTime = Date.now();
const dom_size = getDomSizeWithoutSvg();
Expand All @@ -42,7 +60,7 @@ function start_analyse() {
}

function getDomSizeWithoutSvg() {
let dom_size = document.getElementsByTagName("*").length;
let dom_size = countShadom();
const svgElements = document.getElementsByTagName("svg");
for (let i = 0; i < svgElements.length; i++) {
dom_size -= getNbChildsExcludingNestedSvg(svgElements[i]) - 1;
Expand Down