Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] How to use in the browser? #229

Open
coolaj86 opened this issue Jul 15, 2021 · 0 comments
Open

[docs] How to use in the browser? #229

coolaj86 opened this issue Jul 15, 2021 · 0 comments

Comments

@coolaj86
Copy link

coolaj86 commented Jul 15, 2021

I saw something about UMD support, but there's no snippet for what CDN to grab this from or how to use it in the browser (e.g. What's the name of the global?).

I'm expecting something like this:

Updated This works:

<script src="https://cdn.jsdelivr.net/npm/squirrelly@8.0.8/dist/browser/squirrelly.min.js"></script>
<script>
  window.Sqrl.render("Hi {{it.user}}", {user: "Ada Lovelace"})
</script>

Note to self:

  async function loadScript(src) {
    return await new Promise(function (resolve, reject) {
      var script = document.createElement('script');
      script.src =  src;
      //script.async = false;
      script.onload = resolve;
      script.onerror = reject;
      document.body.append(script);
    });
  }

  loadScript("https://cdn.jsdelivr.net/npm/squirrelly@8.0.8/dist/browser/squirrelly.min.js").then(function () {
    console.log("Loaded.");
  });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant