iconly 1.1.1 → 1.2.1

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/README.md CHANGED
@@ -27,7 +27,7 @@ import Iconly from 'iconly'
27
27
 
28
28
  ```javascript
29
29
  new Iconly({
30
- file: './sprite.svg'
30
+ file: './icons.svg'
31
31
  })
32
32
  ```
33
33
  <br>
package/dist/index.js CHANGED
@@ -11,44 +11,41 @@ $parcel$export(module.exports, "default", () => $4fa36e821943b400$export$2e2bcd8
11
11
  class $4fa36e821943b400$export$2e2bcd8739ae039 {
12
12
  constructor(options){
13
13
  this.options = {
14
+ file: "./icons.svg",
14
15
  ...options
15
16
  };
16
- this.isLocalStorage = !!window["localStorage"];
17
+ this.isLocalStorage = typeof window.localStorage !== "undefined";
17
18
  this.body = document.body;
18
19
  this.init().then();
19
20
  }
20
21
  async init() {
21
22
  const { file: file } = this.options;
22
- if (document.querySelector("#iconset")) return;
23
23
  if (this.isLocalStorage) {
24
24
  const storedSize = localStorage.getItem("inlineSVGsize");
25
- try {
26
- const response = await fetch(file);
27
- if (!response.ok) throw new Error("Network response was not ok");
28
- const data = await response.text();
29
- if (storedSize && storedSize === data.length.toString()) this.insert(localStorage.getItem("inlineSVGdata"));
30
- else {
31
- this.insert(data);
32
- localStorage.setItem("inlineSVGdata", data);
33
- localStorage.setItem("inlineSVGsize", data.length.toString());
34
- }
35
- } catch (error) {
36
- console.error("There was a problem with the network fetch operation:", error);
25
+ const storedData = localStorage.getItem("inlineSVGdata");
26
+ const response = await fetch(file);
27
+ if (!response.ok) throw new Error("Network response was not ok");
28
+ const data = await response.text();
29
+ if (storedSize && storedSize === data.length.toString()) this.insert(storedData);
30
+ else {
31
+ this.insert(data);
32
+ localStorage.setItem("inlineSVGdata", data);
33
+ localStorage.setItem("inlineSVGsize", data.length.toString());
37
34
  }
38
- } else try {
35
+ } else {
39
36
  const response = await fetch(file);
40
37
  if (!response.ok) throw new Error("Network response was not ok");
41
38
  const data = await response.text();
42
39
  this.insert(data);
43
- } catch (error) {
44
- console.error("There was a problem with the network fetch operation:", error);
45
40
  }
46
41
  }
47
42
  insert(data) {
48
- if (this.body) this.body.insertAdjacentHTML("beforeend", data);
49
- else document.addEventListener("DOMContentLoaded", ()=>{
50
- this.body.insertAdjacentHTML("beforeend", data);
51
- });
43
+ if (!document.getElementById("iconset")) {
44
+ if (this.body) this.body.insertAdjacentHTML("beforeend", data);
45
+ else document.addEventListener("DOMContentLoaded", ()=>{
46
+ this.body.insertAdjacentHTML("beforeend", data);
47
+ });
48
+ }
52
49
  }
53
50
  }
54
51
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAe;IACd,YAAY,OAAO,CAAE;QACpB,IAAI,CAAC,UAAU;YAAE,GAAG,OAAO;QAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,CAAE,MAAM,CAAC,eAAe;QAC/C,IAAI,CAAC,OAAO,SAAS;QAErB,IAAI,CAAC,OAAO;IACb;IAEA,MAAM,OAAO;QACZ,MAAM,QAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAEtB,IAAI,SAAS,cAAc,aAAa;QAExC,IAAI,IAAI,CAAC,gBAAgB;YACxB,MAAM,aAAa,aAAa,QAAQ;YAExC,IAAI;gBACH,MAAM,WAAW,MAAM,MAAM;gBAE7B,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,MAAM;gBAElC,MAAM,OAAO,MAAM,SAAS;gBAE5B,IAAI,cAAc,eAAe,KAAK,OAAO,YAC5C,IAAI,CAAC,OAAO,aAAa,QAAQ;qBAC3B;oBACN,IAAI,CAAC,OAAO;oBAEZ,aAAa,QAAQ,iBAAiB;oBACtC,aAAa,QAAQ,iBAAiB,KAAK,OAAO;gBACnD;YACD,EAAE,OAAO,OAAO;gBACf,QAAQ,MAAM,yDAAyD;YACxE;QACD,OACC,IAAI;YACH,MAAM,WAAW,MAAM,MAAM;YAE7B,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,MAAM;YAElC,MAAM,OAAO,MAAM,SAAS;YAE5B,IAAI,CAAC,OAAO;QACb,EAAE,OAAO,OAAO;YACf,QAAQ,MAAM,yDAAyD;QACxE;IAEF;IAEA,OAAO,IAAI,EAAE;QACZ,IAAI,IAAI,CAAC,MACR,IAAI,CAAC,KAAK,mBAAmB,aAAa;aAE1C,SAAS,iBAAiB,oBAAoB;YAC7C,IAAI,CAAC,KAAK,mBAAmB,aAAa;QAC3C;IAEF;AACD","sources":["src/index.js"],"sourcesContent":["export default class Iconly {\r\n\tconstructor(options) {\r\n\t\tthis.options = { ...options }\r\n\t\tthis.isLocalStorage = !!(window['localStorage'])\r\n\t\tthis.body = document.body\r\n\r\n\t\tthis.init().then()\r\n\t}\r\n\r\n\tasync init() {\r\n\t\tconst { file } = this.options\r\n\r\n\t\tif (document.querySelector('#iconset')) return\r\n\r\n\t\tif (this.isLocalStorage) {\r\n\t\t\tconst storedSize = localStorage.getItem('inlineSVGsize')\r\n\r\n\t\t\ttry {\r\n\t\t\t\tconst response = await fetch(file)\r\n\r\n\t\t\t\tif (!response.ok) throw new Error('Network response was not ok')\r\n\r\n\t\t\t\tconst data = await response.text()\r\n\r\n\t\t\t\tif (storedSize && storedSize === data.length.toString()) {\r\n\t\t\t\t\tthis.insert(localStorage.getItem('inlineSVGdata'))\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis.insert(data)\r\n\r\n\t\t\t\t\tlocalStorage.setItem('inlineSVGdata', data)\r\n\t\t\t\t\tlocalStorage.setItem('inlineSVGsize', data.length.toString())\r\n\t\t\t\t}\r\n\t\t\t} catch (error) {\r\n\t\t\t\tconsole.error('There was a problem with the network fetch operation:', error)\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\ttry {\r\n\t\t\t\tconst response = await fetch(file)\r\n\r\n\t\t\t\tif (!response.ok) throw new Error('Network response was not ok')\r\n\r\n\t\t\t\tconst data = await response.text()\r\n\r\n\t\t\t\tthis.insert(data)\r\n\t\t\t} catch (error) {\r\n\t\t\t\tconsole.error('There was a problem with the network fetch operation:', error)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tinsert(data) {\r\n\t\tif (this.body) {\r\n\t\t\tthis.body.insertAdjacentHTML('beforeend', data)\r\n\t\t} else {\r\n\t\t\tdocument.addEventListener('DOMContentLoaded', () => {\r\n\t\t\t\tthis.body.insertAdjacentHTML('beforeend', data)\r\n\t\t\t})\r\n\t\t}\r\n\t}\r\n}"],"names":[],"version":3,"file":"index.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAe;IACd,YAAY,OAAO,CAAE;QACpB,IAAI,CAAC,UAAU;YAAE,MAAM;YAAe,GAAG,OAAO;QAAC;QACjD,IAAI,CAAC,iBAAiB,OAAO,OAAO,iBAAiB;QACrD,IAAI,CAAC,OAAO,SAAS;QAErB,IAAI,CAAC,OAAO;IACb;IAEA,MAAM,OAAO;QACZ,MAAM,QAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAEtB,IAAI,IAAI,CAAC,gBAAgB;YACxB,MAAM,aAAa,aAAa,QAAQ;YACxC,MAAM,aAAa,aAAa,QAAQ;YACxC,MAAM,WAAW,MAAM,MAAM;YAE7B,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,MAAM;YAElC,MAAM,OAAO,MAAM,SAAS;YAE5B,IAAI,cAAc,eAAe,KAAK,OAAO,YAC5C,IAAI,CAAC,OAAO;iBACN;gBACN,IAAI,CAAC,OAAO;gBAEZ,aAAa,QAAQ,iBAAiB;gBACtC,aAAa,QAAQ,iBAAiB,KAAK,OAAO;YACnD;QACD,OAAO;YACN,MAAM,WAAW,MAAM,MAAM;YAE7B,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,MAAM;YAElC,MAAM,OAAO,MAAM,SAAS;YAE5B,IAAI,CAAC,OAAO;QACb;IACD;IAEA,OAAO,IAAI,EAAE;QACZ,IAAI,CAAC,SAAS,eAAe;YAC5B,IAAI,IAAI,CAAC,MACR,IAAI,CAAC,KAAK,mBAAmB,aAAa;iBAE1C,SAAS,iBAAiB,oBAAoB;gBAC7C,IAAI,CAAC,KAAK,mBAAmB,aAAa;YAC3C;;IAGH;AACD","sources":["src/index.js"],"sourcesContent":["export default class Iconly {\r\n\tconstructor(options) {\r\n\t\tthis.options = { file: './icons.svg', ...options }\r\n\t\tthis.isLocalStorage = typeof window.localStorage !== 'undefined'\r\n\t\tthis.body = document.body\r\n\r\n\t\tthis.init().then()\r\n\t}\r\n\r\n\tasync init() {\r\n\t\tconst { file } = this.options\r\n\r\n\t\tif (this.isLocalStorage) {\r\n\t\t\tconst storedSize = localStorage.getItem('inlineSVGsize')\r\n\t\t\tconst storedData = localStorage.getItem('inlineSVGdata')\r\n\t\t\tconst response = await fetch(file)\r\n\r\n\t\t\tif (!response.ok) throw new Error('Network response was not ok')\r\n\r\n\t\t\tconst data = await response.text()\r\n\r\n\t\t\tif (storedSize && storedSize === data.length.toString()) {\r\n\t\t\t\tthis.insert(storedData)\r\n\t\t\t} else {\r\n\t\t\t\tthis.insert(data)\r\n\r\n\t\t\t\tlocalStorage.setItem('inlineSVGdata', data)\r\n\t\t\t\tlocalStorage.setItem('inlineSVGsize', data.length.toString())\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tconst response = await fetch(file)\r\n\r\n\t\t\tif (!response.ok) throw new Error('Network response was not ok')\r\n\r\n\t\t\tconst data = await response.text()\r\n\r\n\t\t\tthis.insert(data)\r\n\t\t}\r\n\t}\r\n\r\n\tinsert(data) {\r\n\t\tif (!document.getElementById('iconset')) {\r\n\t\t\tif (this.body) {\r\n\t\t\t\tthis.body.insertAdjacentHTML('beforeend', data)\r\n\t\t\t} else {\r\n\t\t\t\tdocument.addEventListener('DOMContentLoaded', () => {\r\n\t\t\t\t\tthis.body.insertAdjacentHTML('beforeend', data)\r\n\t\t\t\t})\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}"],"names":[],"version":3,"file":"index.js.map"}
@@ -1,44 +1,41 @@
1
1
  class $cf838c15c8b009ba$export$2e2bcd8739ae039 {
2
2
  constructor(options){
3
3
  this.options = {
4
+ file: "./icons.svg",
4
5
  ...options
5
6
  };
6
- this.isLocalStorage = !!window["localStorage"];
7
+ this.isLocalStorage = typeof window.localStorage !== "undefined";
7
8
  this.body = document.body;
8
9
  this.init().then();
9
10
  }
10
11
  async init() {
11
12
  const { file: file } = this.options;
12
- if (document.querySelector("#iconset")) return;
13
13
  if (this.isLocalStorage) {
14
14
  const storedSize = localStorage.getItem("inlineSVGsize");
15
- try {
16
- const response = await fetch(file);
17
- if (!response.ok) throw new Error("Network response was not ok");
18
- const data = await response.text();
19
- if (storedSize && storedSize === data.length.toString()) this.insert(localStorage.getItem("inlineSVGdata"));
20
- else {
21
- this.insert(data);
22
- localStorage.setItem("inlineSVGdata", data);
23
- localStorage.setItem("inlineSVGsize", data.length.toString());
24
- }
25
- } catch (error) {
26
- console.error("There was a problem with the network fetch operation:", error);
15
+ const storedData = localStorage.getItem("inlineSVGdata");
16
+ const response = await fetch(file);
17
+ if (!response.ok) throw new Error("Network response was not ok");
18
+ const data = await response.text();
19
+ if (storedSize && storedSize === data.length.toString()) this.insert(storedData);
20
+ else {
21
+ this.insert(data);
22
+ localStorage.setItem("inlineSVGdata", data);
23
+ localStorage.setItem("inlineSVGsize", data.length.toString());
27
24
  }
28
- } else try {
25
+ } else {
29
26
  const response = await fetch(file);
30
27
  if (!response.ok) throw new Error("Network response was not ok");
31
28
  const data = await response.text();
32
29
  this.insert(data);
33
- } catch (error) {
34
- console.error("There was a problem with the network fetch operation:", error);
35
30
  }
36
31
  }
37
32
  insert(data) {
38
- if (this.body) this.body.insertAdjacentHTML("beforeend", data);
39
- else document.addEventListener("DOMContentLoaded", ()=>{
40
- this.body.insertAdjacentHTML("beforeend", data);
41
- });
33
+ if (!document.getElementById("iconset")) {
34
+ if (this.body) this.body.insertAdjacentHTML("beforeend", data);
35
+ else document.addEventListener("DOMContentLoaded", ()=>{
36
+ this.body.insertAdjacentHTML("beforeend", data);
37
+ });
38
+ }
42
39
  }
43
40
  }
44
41
 
@@ -1 +1 @@
1
- {"mappings":"AAAe;IACd,YAAY,OAAO,CAAE;QACpB,IAAI,CAAC,UAAU;YAAE,GAAG,OAAO;QAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,CAAE,MAAM,CAAC,eAAe;QAC/C,IAAI,CAAC,OAAO,SAAS;QAErB,IAAI,CAAC,OAAO;IACb;IAEA,MAAM,OAAO;QACZ,MAAM,QAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAEtB,IAAI,SAAS,cAAc,aAAa;QAExC,IAAI,IAAI,CAAC,gBAAgB;YACxB,MAAM,aAAa,aAAa,QAAQ;YAExC,IAAI;gBACH,MAAM,WAAW,MAAM,MAAM;gBAE7B,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,MAAM;gBAElC,MAAM,OAAO,MAAM,SAAS;gBAE5B,IAAI,cAAc,eAAe,KAAK,OAAO,YAC5C,IAAI,CAAC,OAAO,aAAa,QAAQ;qBAC3B;oBACN,IAAI,CAAC,OAAO;oBAEZ,aAAa,QAAQ,iBAAiB;oBACtC,aAAa,QAAQ,iBAAiB,KAAK,OAAO;gBACnD;YACD,EAAE,OAAO,OAAO;gBACf,QAAQ,MAAM,yDAAyD;YACxE;QACD,OACC,IAAI;YACH,MAAM,WAAW,MAAM,MAAM;YAE7B,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,MAAM;YAElC,MAAM,OAAO,MAAM,SAAS;YAE5B,IAAI,CAAC,OAAO;QACb,EAAE,OAAO,OAAO;YACf,QAAQ,MAAM,yDAAyD;QACxE;IAEF;IAEA,OAAO,IAAI,EAAE;QACZ,IAAI,IAAI,CAAC,MACR,IAAI,CAAC,KAAK,mBAAmB,aAAa;aAE1C,SAAS,iBAAiB,oBAAoB;YAC7C,IAAI,CAAC,KAAK,mBAAmB,aAAa;QAC3C;IAEF;AACD","sources":["src/index.js"],"sourcesContent":["export default class Iconly {\r\n\tconstructor(options) {\r\n\t\tthis.options = { ...options }\r\n\t\tthis.isLocalStorage = !!(window['localStorage'])\r\n\t\tthis.body = document.body\r\n\r\n\t\tthis.init().then()\r\n\t}\r\n\r\n\tasync init() {\r\n\t\tconst { file } = this.options\r\n\r\n\t\tif (document.querySelector('#iconset')) return\r\n\r\n\t\tif (this.isLocalStorage) {\r\n\t\t\tconst storedSize = localStorage.getItem('inlineSVGsize')\r\n\r\n\t\t\ttry {\r\n\t\t\t\tconst response = await fetch(file)\r\n\r\n\t\t\t\tif (!response.ok) throw new Error('Network response was not ok')\r\n\r\n\t\t\t\tconst data = await response.text()\r\n\r\n\t\t\t\tif (storedSize && storedSize === data.length.toString()) {\r\n\t\t\t\t\tthis.insert(localStorage.getItem('inlineSVGdata'))\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis.insert(data)\r\n\r\n\t\t\t\t\tlocalStorage.setItem('inlineSVGdata', data)\r\n\t\t\t\t\tlocalStorage.setItem('inlineSVGsize', data.length.toString())\r\n\t\t\t\t}\r\n\t\t\t} catch (error) {\r\n\t\t\t\tconsole.error('There was a problem with the network fetch operation:', error)\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\ttry {\r\n\t\t\t\tconst response = await fetch(file)\r\n\r\n\t\t\t\tif (!response.ok) throw new Error('Network response was not ok')\r\n\r\n\t\t\t\tconst data = await response.text()\r\n\r\n\t\t\t\tthis.insert(data)\r\n\t\t\t} catch (error) {\r\n\t\t\t\tconsole.error('There was a problem with the network fetch operation:', error)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tinsert(data) {\r\n\t\tif (this.body) {\r\n\t\t\tthis.body.insertAdjacentHTML('beforeend', data)\r\n\t\t} else {\r\n\t\t\tdocument.addEventListener('DOMContentLoaded', () => {\r\n\t\t\t\tthis.body.insertAdjacentHTML('beforeend', data)\r\n\t\t\t})\r\n\t\t}\r\n\t}\r\n}"],"names":[],"version":3,"file":"index.module.js.map"}
1
+ {"mappings":"AAAe;IACd,YAAY,OAAO,CAAE;QACpB,IAAI,CAAC,UAAU;YAAE,MAAM;YAAe,GAAG,OAAO;QAAC;QACjD,IAAI,CAAC,iBAAiB,OAAO,OAAO,iBAAiB;QACrD,IAAI,CAAC,OAAO,SAAS;QAErB,IAAI,CAAC,OAAO;IACb;IAEA,MAAM,OAAO;QACZ,MAAM,QAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAEtB,IAAI,IAAI,CAAC,gBAAgB;YACxB,MAAM,aAAa,aAAa,QAAQ;YACxC,MAAM,aAAa,aAAa,QAAQ;YACxC,MAAM,WAAW,MAAM,MAAM;YAE7B,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,MAAM;YAElC,MAAM,OAAO,MAAM,SAAS;YAE5B,IAAI,cAAc,eAAe,KAAK,OAAO,YAC5C,IAAI,CAAC,OAAO;iBACN;gBACN,IAAI,CAAC,OAAO;gBAEZ,aAAa,QAAQ,iBAAiB;gBACtC,aAAa,QAAQ,iBAAiB,KAAK,OAAO;YACnD;QACD,OAAO;YACN,MAAM,WAAW,MAAM,MAAM;YAE7B,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,MAAM;YAElC,MAAM,OAAO,MAAM,SAAS;YAE5B,IAAI,CAAC,OAAO;QACb;IACD;IAEA,OAAO,IAAI,EAAE;QACZ,IAAI,CAAC,SAAS,eAAe;YAC5B,IAAI,IAAI,CAAC,MACR,IAAI,CAAC,KAAK,mBAAmB,aAAa;iBAE1C,SAAS,iBAAiB,oBAAoB;gBAC7C,IAAI,CAAC,KAAK,mBAAmB,aAAa;YAC3C;;IAGH;AACD","sources":["src/index.js"],"sourcesContent":["export default class Iconly {\r\n\tconstructor(options) {\r\n\t\tthis.options = { file: './icons.svg', ...options }\r\n\t\tthis.isLocalStorage = typeof window.localStorage !== 'undefined'\r\n\t\tthis.body = document.body\r\n\r\n\t\tthis.init().then()\r\n\t}\r\n\r\n\tasync init() {\r\n\t\tconst { file } = this.options\r\n\r\n\t\tif (this.isLocalStorage) {\r\n\t\t\tconst storedSize = localStorage.getItem('inlineSVGsize')\r\n\t\t\tconst storedData = localStorage.getItem('inlineSVGdata')\r\n\t\t\tconst response = await fetch(file)\r\n\r\n\t\t\tif (!response.ok) throw new Error('Network response was not ok')\r\n\r\n\t\t\tconst data = await response.text()\r\n\r\n\t\t\tif (storedSize && storedSize === data.length.toString()) {\r\n\t\t\t\tthis.insert(storedData)\r\n\t\t\t} else {\r\n\t\t\t\tthis.insert(data)\r\n\r\n\t\t\t\tlocalStorage.setItem('inlineSVGdata', data)\r\n\t\t\t\tlocalStorage.setItem('inlineSVGsize', data.length.toString())\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tconst response = await fetch(file)\r\n\r\n\t\t\tif (!response.ok) throw new Error('Network response was not ok')\r\n\r\n\t\t\tconst data = await response.text()\r\n\r\n\t\t\tthis.insert(data)\r\n\t\t}\r\n\t}\r\n\r\n\tinsert(data) {\r\n\t\tif (!document.getElementById('iconset')) {\r\n\t\t\tif (this.body) {\r\n\t\t\t\tthis.body.insertAdjacentHTML('beforeend', data)\r\n\t\t\t} else {\r\n\t\t\t\tdocument.addEventListener('DOMContentLoaded', () => {\r\n\t\t\t\t\tthis.body.insertAdjacentHTML('beforeend', data)\r\n\t\t\t\t})\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}"],"names":[],"version":3,"file":"index.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iconly",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "description": "SVG Sprite",
5
5
  "author": "ux-ui.pro",
6
6
  "license": "MIT",
package/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export default class Iconly {
2
2
  constructor(options) {
3
- this.options = { ...options }
4
- this.isLocalStorage = !!(window['localStorage'])
3
+ this.options = { file: './icons.svg', ...options }
4
+ this.isLocalStorage = typeof window.localStorage !== 'undefined'
5
5
  this.body = document.body
6
6
 
7
7
  this.init().then()
@@ -10,51 +10,43 @@ export default class Iconly {
10
10
  async init() {
11
11
  const { file } = this.options
12
12
 
13
- if (document.querySelector('#iconset')) return
14
-
15
13
  if (this.isLocalStorage) {
16
14
  const storedSize = localStorage.getItem('inlineSVGsize')
15
+ const storedData = localStorage.getItem('inlineSVGdata')
16
+ const response = await fetch(file)
17
17
 
18
- try {
19
- const response = await fetch(file)
20
-
21
- if (!response.ok) throw new Error('Network response was not ok')
18
+ if (!response.ok) throw new Error('Network response was not ok')
22
19
 
23
- const data = await response.text()
20
+ const data = await response.text()
24
21
 
25
- if (storedSize && storedSize === data.length.toString()) {
26
- this.insert(localStorage.getItem('inlineSVGdata'))
27
- } else {
28
- this.insert(data)
22
+ if (storedSize && storedSize === data.length.toString()) {
23
+ this.insert(storedData)
24
+ } else {
25
+ this.insert(data)
29
26
 
30
- localStorage.setItem('inlineSVGdata', data)
31
- localStorage.setItem('inlineSVGsize', data.length.toString())
32
- }
33
- } catch (error) {
34
- console.error('There was a problem with the network fetch operation:', error)
27
+ localStorage.setItem('inlineSVGdata', data)
28
+ localStorage.setItem('inlineSVGsize', data.length.toString())
35
29
  }
36
30
  } else {
37
- try {
38
- const response = await fetch(file)
31
+ const response = await fetch(file)
39
32
 
40
- if (!response.ok) throw new Error('Network response was not ok')
33
+ if (!response.ok) throw new Error('Network response was not ok')
41
34
 
42
- const data = await response.text()
35
+ const data = await response.text()
43
36
 
44
- this.insert(data)
45
- } catch (error) {
46
- console.error('There was a problem with the network fetch operation:', error)
47
- }
37
+ this.insert(data)
48
38
  }
49
39
  }
50
40
 
51
41
  insert(data) {
52
- if (this.body) {
53
- this.body.insertAdjacentHTML('beforeend', data)
54
- } else {
55
- document.addEventListener('DOMContentLoaded', () => {
42
+ if (!document.getElementById('iconset')) {
43
+ if (this.body) {
56
44
  this.body.insertAdjacentHTML('beforeend', data)
57
- })
45
+ } else {
46
+ document.addEventListener('DOMContentLoaded', () => {
47
+ this.body.insertAdjacentHTML('beforeend', data)
48
+ })
49
+ }
58
50
  }
59
51
  }
60
52
  }