Skip to content

Instantly share code, notes, and snippets.

@sbilodeau
Last active November 5, 2018 14:49
Show Gist options
  • Save sbilodeau/29c8016b67485614944e to your computer and use it in GitHub Desktop.
Save sbilodeau/29c8016b67485614944e to your computer and use it in GitHub Desktop.
Slaask with requireJS using <script/> tag
<!--
Slaask is not working when used with requirejs
Place this slaask script tags just before the requirejs one
-->
<script src="https://cdn.slaask.com/chat.js"></script>
<script>
//Override _slaask.createScriptTag to use requireJS to load injected module 'Pusher'
window._slaask.createScriptTag = function (url) {
var t = {};
require([url], function() { t.onload(); });
return t;
};
</script>
<!-- Boot the requirejs app -->
<script src="path/to/require.js" data-main="path/to/main.js"></script>
<script>
// The following line can be moved into your requirejs booted app
_slaask.init('xxxxxxxxxxxxx');
</script>
@rdlh
Copy link

rdlh commented Mar 7, 2016

Hey! Slaask lead developer here.

Can you please add the _slaask.init('xxxxxxxxxx') line for non-tech users?

Anyway, thank you so much for this code snippet.
We really appreciate ❤️

@Shyked
Copy link

Shyked commented Nov 5, 2018

Hello! Rémy from Slaask here

Slaask now supports RequireJS without the need of a custom fix! 🎉

You should avoid overriding the createScriptTag function from now, as it may introduce unexpected behaviors 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment