Skip to content

Commit

Permalink
Properly set script attributes and async / defer - fixes #104 #103
Browse files Browse the repository at this point in the history
  • Loading branch information
porsager committed Oct 30, 2021
1 parent e422832 commit e7ce16f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/srcdoc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,13 @@ function loadRemoteScript(script) {
}
const el = create('script', {
charset: 'utf-8',
async: false,
defer: false,
src: script.url
})

el.async = el.defer = false

if (script.el)
Array.prototype.slice.call(script.el.attributes).forEach(a => el.setAttribute(a.name, a.value))
Array.prototype.slice.call(script.el.attributes).forEach(a => el[a.name] = a.value)

el.onload = () => resolve()
el.onerror = err => reject([script.url, err])
Expand Down Expand Up @@ -318,13 +318,13 @@ window.flemsLoadScript = function flemsLoadScript(script) {
const el = create('script', {
src: url,
charset: 'utf-8',
async: false,
defer: false,
type: script.module ? 'module' : ''
})

el.async = el.defer = false

if (script.el)
Array.prototype.slice.call(script.el.attributes).forEach(a => a.name !== 'type' && el.setAttribute(a.name, a.value))
Array.prototype.slice.call(script.el.attributes).forEach(a => el[a.name] = a.value)

el.onerror = reject
el.onload = resolve
Expand Down

0 comments on commit e7ce16f

Please sign in to comment.