Last active
June 12, 2023 12:03
-
-
Save volandku/50de5fcff12d0240f7fe40aeb278442e to your computer and use it in GitHub Desktop.
од для модуля (джумлы, но не только) для вставки яндекс карты отложенно на 4 секунды для улучшения показателей Google PageSpeed
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
// код для модуля (джумлы, но не только) для вставки яндекс карты отложенно на 4 секунды для улучшения показателей Google PageSpeed | |
// смените url перед использованием | |
<div id="ymaps111" style="display: block; width: 100%; height: 500px;"></div> | |
<script type="text/javascript"> | |
function loadScript(url, callback){ | |
var script = document.createElement("script"); | |
if (script.readyState){ // IE | |
script.onreadystatechange = function(){ | |
if (script.readyState == "loaded" || | |
script.readyState == "complete"){ | |
script.onreadystatechange = null; | |
callback(); | |
} | |
}; | |
} else { // Другие браузеры | |
script.onload = function(){ | |
callback(); | |
}; | |
} | |
script.src = url; | |
document.getElementById("ymaps111").append(script); | |
} | |
document.addEventListener("DOMContentLoaded", function() { | |
setTimeout(function(){ | |
loadScript("https://api-maps.yandex.ru/services/constructor/1.0/js/?um=constructor%3Aтутдлинныйидентификатор&width=100%&height=500&lang=ru_RU&scroll=true" , | |
function(){ ye();}); | |
},4000); | |
}); | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Спасибо, мужик! Снёс api яндекса из head и сайт аж дышать начал!