@foeewni/web-core 2.8.1 → 2.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/fonts.js CHANGED
@@ -136,13 +136,16 @@ library.add(
136
136
  // We avoiding using @import url(); because the new URL has semicolons on it
137
137
  // and it tremendously gets broken from some preprocessors.
138
138
 
139
- const fonts = window.document.createElement('link');
140
139
  // eslint-disable-next-line max-len
141
- const href = 'https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital@0;1&family=Libre+Franklin:ital,wght@0,400;0,700;1,400;1,700&display=swap';
142
- fonts.setAttribute('rel', 'stylesheet');
143
- fonts.setAttribute('crossorigin', 'anonymous');
144
- fonts.setAttribute('href', href);
145
- document.head.appendChild(fonts);
140
+ const googleFontsHref = 'https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital@0;1&family=Libre+Franklin:ital,wght@0,400;0,700;1,400;1,700&display=swap';
141
+ const googleFontsLink = window.document.querySelector(`link[href="${googleFontsHref}"]`);
142
+ if (!googleFontsLink) {
143
+ const fonts = window.document.createElement('link');
144
+ fonts.setAttribute('rel', 'stylesheet');
145
+ fonts.setAttribute('crossorigin', 'anonymous');
146
+ fonts.setAttribute('href', googleFontsHref);
147
+ document.head.appendChild(fonts);
148
+ }
146
149
 
147
150
  // Kicks off the process of finding <i> tags and replacing with <svg>
148
151
  dom.watch();