Skip to content

Commit e002339

Browse files
authored
Measure rel attributes plus all link elements (#192)
Measure `rel` attributes plud all link elements
1 parent c19b07d commit e002339

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

dist/almanac.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ return JSON.stringify({
209209
'link-nodes': (() => {
210210
// Returns a JSON array of link nodes and their key/value attributes.
211211
// Used by 01.14, 01.15, 01.16, 10.6, 06.46, 12.18
212-
var nodes = document.querySelectorAll('head link');
212+
var nodes = document.querySelectorAll('link');
213213
return parseNodes(nodes);
214214
})(),
215215
'priority-hints': (() => {

dist/markup.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,33 @@ try { // whole process is placed in a try/catch so we can log uncaught errors
294294
}
295295
})(),
296296

297+
// rel attribute usage
298+
'rel': (() => {
299+
try {
300+
let result = {rels_total: 0, rels: {}};
301+
302+
const nodes = document.querySelectorAll('*[rel]');
303+
304+
nodes.forEach((n) => {
305+
306+
result.rels_total++;
307+
308+
if (result.rels[n.rel]) {
309+
result.rels[n.rel]++;
310+
}
311+
else {
312+
result.rels[n.rel] = 1;
313+
}
314+
315+
});
316+
317+
return result;
318+
}
319+
catch(e) {
320+
return logError("rel", e);
321+
}
322+
})(),
323+
297324
// id attribute usage
298325
// Used by Markup
299326
'ids': (() => {

metric-summary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Whether the page contains any instances of <script nomodule>
1515
`1` if true, `0` if false
1616

1717
## link-nodes
18-
A JSON array of <link> nodes used in the <head> element.
18+
A JSON array of <link> nodes
1919

2020
Example response:
2121

0 commit comments

Comments
 (0)