Last active
November 5, 2018 14:49
-
-
Save sbilodeau/29c8016b67485614944e to your computer and use it in GitHub Desktop.
Slaask with requireJS using <script/> tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 🤔