Muut
November 29, 2016, 9:47am
1
Hello, does Grav asynchronous loading of scripts?
<div id="vk_api_transport"></div>
<script type="text/javascript">
window.vkAsyncInit = function() {
VK.init({
apiId: APP_ID
});
};
setTimeout(function() {
var el = document.createElement("script");
el.type = "text/javascript";
el.src = "https://vk.com/js/api/openapi.js?136";
el.async = true;
document.getElementById("vk_api_transport").appendChild(el);
}, 0);
</script>
This code does not work.
Thanks.
Muut
November 29, 2016, 12:23pm
2
I don’t see how Grav would influence that at all. All Grav does is generate the HTML. Is that code making it to the final page?
Muut
November 29, 2016, 2:02pm
3
As Perlkonig says, the JS you pasted creates an HTML <script>
tag and fills the attributes. There is nothing that is Grav-related here.
Muut
November 30, 2016, 3:53pm
4
Thank you for your attention. I think the same, but the example I took from the documentation from professional developers social network. A shorter version of the script, not asynchronous, it works. Just like the codes slow down the loading of the page.