Skip to content

Commit 947091a

Browse files
committed
chore(): add install loader script
1 parent 728aa74 commit 947091a

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ dist/
1717
icons/
1818
.DS_Store
1919
scripts/*.js
20+
!scripts/install-loader.js
2021

2122
www/

scripts/install-loader.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
(function(doc){
3+
var scriptElm = doc.scripts[doc.scripts.length - 1];
4+
var warn = ['[ionicons] Deprecated script, please remove: ' + scriptElm.outerHTML];
5+
6+
warn.push('To improve performance it is recommended to set the differential scripts in the head as follows:')
7+
8+
var parts = scriptElm.src.split('/');
9+
parts.pop();
10+
parts.push('ionicons');
11+
var url = parts.join('/');
12+
13+
var scriptElm = doc.createElement('script');
14+
scriptElm.setAttribute('type', 'module');
15+
scriptElm.src = url + '/ionicons.esm.js';
16+
warn.push(scriptElm.outerHTML);
17+
scriptElm.setAttribute('data-stencil-namespace', 'ionicons');
18+
doc.head.appendChild(scriptElm);
19+
20+
21+
scriptElm = doc.createElement('script');
22+
scriptElm.setAttribute('nomodule', '');
23+
scriptElm.src = url + '/ionicons.js';
24+
warn.push(scriptElm.outerHTML);
25+
scriptElm.setAttribute('data-stencil-namespace', 'ionicons');
26+
doc.head.appendChild(scriptElm)
27+
28+
console.warn(warn.join('\n'));
29+
30+
})(document);

0 commit comments

Comments
 (0)