Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rafszul/048e66eb5cc9d95de93e516b67a8cc09 to your computer and use it in GitHub Desktop.
Save rafszul/048e66eb5cc9d95de93e516b67a8cc09 to your computer and use it in GitHub Desktop.

Revisions

  1. @freddielore freddielore created this gist Jun 28, 2019.
    33 changes: 33 additions & 0 deletions public-defer-javascript.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    <script type="text/javascript">

    var app = {
    init: function() {
    window.addEventListener('scroll', function() {
    if (window.__he == undefined) {
    app.load();
    }
    });
    window.addEventListener('mousemove', function() {
    if (window.__he == undefined) {
    app.load();
    }
    });
    },
    load: function() {
    var script = document.createElement('script');
    script.src = '//healthengine.com.au/webplugin/appointments.js';
    script.defer = true;
    script.setAttribute('data-he-id', 'foo');
    script.setAttribute('data-he-button', 'true');
    script.setAttribute('data-he-img', 'HE_BOOKNOW_1.png');
    document.getElementById('health-engine').appendChild(script);
    script.onload = function() {
    window['__he'] = true;
    }
    window['__he'] = true;
    }
    };

    app.init();

    </script>