Skip to content

Instantly share code, notes, and snippets.

@ernestofreyreg
Created December 1, 2020 02:15
Show Gist options
  • Save ernestofreyreg/c248a9c180ce7277d5e4b12de2f6e5cb to your computer and use it in GitHub Desktop.
Save ernestofreyreg/c248a9c180ce7277d5e4b12de2f6e5cb to your computer and use it in GitHub Desktop.
;(function () {
var w = window
var mc = w.mortgage_calculator
if (typeof mc === 'object') {
mc.renderMortgageCalculator(document.getElementById('root'))
} else {
var d = document
var l = function () {
var s = d.createElement('script')
s.type = 'text/javascript'
s.async = true
s.src = 'mortgage-calculator.js'
var x = d.getElementsByTagName('script')[0]
x.parentNode.insertBefore(s, x)
s.onload = () => {
w.mortgage_calculator.renderMortgageCalculator(document.getElementById('root'))
}
}
if (document.readyState === 'complete') {
l()
} else if (w.attachEvent) {
w.attachEvent('onload', l)
} else {
w.addEventListener('load', l, false)
}
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment