Skip to content

Commit 92ecc1b

Browse files
committed
fix(index): dynamic css loading support for older browsers (#294)
1 parent eb218cc commit 92ecc1b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/index.js

+12
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,18 @@ class MiniCssExtractPlugin {
365365
'linkTag.href = fullhref;',
366366
'var head = document.getElementsByTagName("head")[0];',
367367
'head.appendChild(linkTag);',
368+
"// old webkit's would claim to have onload, but didn't really support it",
369+
'// https://github.com/kriszyp/xstyle/blob/master/core/load-css.js',
370+
'var webkitVersion = navigator.userAgent.match(/AppleWebKit\\/(\\d+\\.?\\d*)/);',
371+
'webkitVersion = webkitVersion && +webkitVersion[1];',
372+
'if (webkitVersion < 536) {',
373+
Template.indent([
374+
'// http://www.backalleycoder.com/2011/03/20/link-tag-css-stylesheet-load-event/',
375+
'var img = document.createElement("img");',
376+
'img.onerror = resolve;',
377+
`img.src = fullhref;`,
378+
]),
379+
'}',
368380
]),
369381
'}).then(function() {',
370382
Template.indent(['installedCssChunks[chunkId] = 0;']),

0 commit comments

Comments
 (0)