-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiframe2.html
More file actions
88 lines (76 loc) · 3.34 KB
/
iframe2.html
File metadata and controls
88 lines (76 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html>
<html>
<head>
<title>IFrame Test</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
background: #fff3cd;
}
.result {
background: white;
padding: 10px;
border-radius: 4px;
margin: 10px 0;
font-family: monospace;
word-break: break-all;
}
</style>
</head>
<body>
<h3>IFrame Context</h3>
<div>Without API Key:</div>
<div class="result" id="withoutKey">Loading...</div>
<div>With API Key:</div>
<div class="result" id="withKey">Loading...</div>
<script src="thumbmark.umd.js"></script>
<script>
(async function () {
try {
const API_KEY = '6c5e18e199f82882f0a9539a5ff5df8b';
// Without API key
console.log('[IFrame] Starting thumbmark without API key...');
const startWithoutKey = performance.now();
const thumbmarkWithoutKey = new ThumbmarkJS.Thumbmark({ performance: true });
const resultWithoutKey = await thumbmarkWithoutKey.get();
const elapsedWithoutKey = performance.now() - startWithoutKey;
console.log(`[IFrame] Without API key completed in ${elapsedWithoutKey.toFixed(2)}ms`);
// Log performance for each component
if (resultWithoutKey.performance) {
console.log('[IFrame] Component timings (without API key):');
Object.entries(resultWithoutKey.performance).forEach(([component, time]) => {
console.log(` ${component}: ${time}ms`);
});
}
document.getElementById('withoutKey').textContent = resultWithoutKey.thumbmark;
// With API key
console.log('[IFrame] Starting thumbmark with API key...');
const startWithKey = performance.now();
const thumbmarkWithKey = new ThumbmarkJS.Thumbmark({ api_endpoint: 'https://api.thumbmarkjs.com', api_key: API_KEY, performance: true, stabilize: ['iframe'] });
const resultWithKey = await thumbmarkWithKey.get();
const elapsedWithKey = performance.now() - startWithKey;
console.log(`[IFrame] With API key completed in ${elapsedWithKey.toFixed(2)}ms`);
// Log performance for each component
if (resultWithKey.performance) {
console.log('[IFrame] Component timings (with API key):');
Object.entries(resultWithKey.performance).forEach(([component, time]) => {
console.log(` ${component}: ${time}ms`);
});
}
document.getElementById('withKey').textContent = resultWithKey.thumbmark;
// Send results to parent
window.parent.postMessage({
type: 'thumbmark-results',
withoutKey: resultWithoutKey.thumbmark,
withKey: resultWithKey.thumbmark,
resultWithoutKey: resultWithoutKey,
resultWithKey: resultWithKey
}, '*');
} catch (error) {
console.error('IFrame error:', error);
}
})();
</script>
</body>
</html>