Skip to content

Instantly share code, notes, and snippets.

@anasnakawa
Last active January 3, 2018 14:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anasnakawa/770a37ecda3a023e41b5104391535ce1 to your computer and use it in GitHub Desktop.
Save anasnakawa/770a37ecda3a023e41b5104391535ce1 to your computer and use it in GitHub Desktop.
<script type="text/javascript">
(function() {
'use strict';
/**
* hook method to be executed as soon as shortpoint
* is available in the page
*/
function initHook() {
// exit on edit mode
if( window.shortPointInserter ) {
return;
}
setTimeout(function() {
// shortpoint is ready and rendered on the page
var jsElm = document.createElement("script");
// set the type attribute
jsElm.type = "application/javascript";
// make the script element load file
jsElm.src = "//platform.twitter.com/widgets.js";
// finally insert the element to the body element in order to load the script
document.body.appendChild(jsElm);
}, 500);
};
// shortpoint not yet available in the page
// wait for shortpoint ready dom event
document.addEventListener( 'shortpoint-render-above-fold', initHook );
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment