Skip to content

Instantly share code, notes, and snippets.

@hozefaj
Last active January 20, 2019 18:01
Show Gist options
  • Save hozefaj/009f98a4b3e23d922342f6cfeb833b79 to your computer and use it in GitHub Desktop.
Save hozefaj/009f98a4b3e23d922342f6cfeb833b79 to your computer and use it in GitHub Desktop.

Revisions

  1. hozefaj revised this gist Jan 20, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion delaybundle.js
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ function() {
    });
    });

    // defer laoding for the client side JS after DOM loaded event
    // defer loading for the client side JS after DOM loaded event
    // this is because we are doing SSR
    function(){
    function loadScript(src, cb) {
  2. hozefaj revised this gist Jan 20, 2019. No changes.
  3. hozefaj revised this gist Jan 20, 2019. 1 changed file with 32 additions and 2 deletions.
    34 changes: 32 additions & 2 deletions delaybundle.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    (function() {
    // defer loading of non-essential JS until DOM loaded event
    function() {
    window.addEventListener("load", function() {
    var s, t;
    s = document.createElement("script");
    @@ -8,4 +9,33 @@
    t = document.getElementsByTagName("body")[0];
    t.appendChild(s);
    });
    })();
    });

    // defer laoding for the client side JS after DOM loaded event
    // this is because we are doing SSR
    function(){
    function loadScript(src, cb) {
    var s, r, t;
    r = false;
    s = document.createElement("script");
    s.type = "text/javascript";
    s.src = src;
    s.onload = s.onreadystatechange = function() {
    if (!r && (!this.readyState || this.readyState == "complete")) {
    r = true;
    cb();
    }
    };
    t = document.getElementsByTagName("body")[0];
    t.appendChild(s);
    }
    function mountCode() {
    if (typeof window !== "undefined" && window.document && window.document.createElement) {
    var appElement = React.createElement(window.PageBundle.default, {modelData: window.modelData});
    ReactDOM.hydrate(appElement, window.document.getElementById("app-element-mountpoint"));
    }
    }
    window.addEventListener('load', function() {
    loadScript("https://www.paypalobjects.com/eboxapps/js/5f/7981d3071109ab488093d2ba7e4ca87ff7629e.js", mountCode);
    });
    });
  4. hozefaj revised this gist Jan 20, 2019. No changes.
  5. hozefaj created this gist Jan 20, 2019.
    11 changes: 11 additions & 0 deletions delaybundle.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    (function() {
    window.addEventListener("load", function() {
    var s, t;
    s = document.createElement("script");
    s.type = "text/javascript";
    s.src =
    "https://www.paypalobjects.com/digitalassets/c/website/marketing/global/kui/js/opinionLab-2.1.0.js";
    t = document.getElementsByTagName("body")[0];
    t.appendChild(s);
    });
    })();