We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 06ee42f commit d8ee292Copy full SHA for d8ee292
fathom-data-attr.js
@@ -1,12 +1,22 @@
1
-const spaValue = "auto";
+(function(){
2
+ let attempts = 0;
3
-function addDataAttr() {
4
- const el = document.getElementById("fathom-script");
5
- const dataSpaValue = el.dataset.spa;
+ function addDataAttr() {
+ const spaValue = "auto";
6
+ const el = document.getElementById("fathom-script");
7
+ attempts += 1;
8
+
9
+ if (!el && attempts < 10) {
10
+ window.setTimeout(addDataAttr, 100);
11
+ return;
12
+ }
13
- if (dataSpaValue === undefined) {
- el.dataset.spa = spaValue;
14
+ const dataSpaValue = el.dataset.spa;
15
16
+ if (dataSpaValue === undefined) {
17
+ el.dataset.spa = spaValue;
18
19
}
-}
20
-addDataAttr();
21
+ addDataAttr();
22
+})();
0 commit comments