Created
June 3, 2017 15:02
-
-
Save dimobelov/9d43a358315149b6a2578f476d33334f to your computer and use it in GitHub Desktop.
Как Google зарежда javascipt на блоговете си.
This file contains hidden or 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
<-- от https://blog.google --> | |
<div id="base-scripts" data-scripts='[ | |
{ "url": "https://storage.googleapis.com/gweb-uniblog-publish-prod/static/blog/js/data-layer-analytics.da7f878b7c0e.js", | |
"options": { | |
"async": false, | |
"defer": false | |
} | |
}, | |
{ "url": "https://storage.googleapis.com/gweb-uniblog-publish-prod/static/blog/js/gtm.d797bb14a102.js", | |
"options": { | |
"async": false, | |
"defer": false | |
} | |
}, | |
{ "url": "https://storage.googleapis.com/gweb-uniblog-publish-prod/static/blog/js/blog.d01c571380f3.js", | |
"options": { | |
"async": true, | |
"defer": false | |
} | |
}, | |
{ "url": "https://storage.googleapis.com/gweb-uniblog-publish-prod/static/blog/js/vendors.10b0b9cbacd5.js", | |
"options": { | |
"async": true, | |
"defer": false | |
} | |
} | |
]'></div> | |
<script type="text/javascript"> | |
var scripts = document.querySelector("#base-scripts").getAttribute('data-scripts'); | |
scripts = JSON.parse(scripts); | |
scripts.forEach(function(scriptObj) { | |
var s = document.createElement('script'); | |
s.async = scriptObj.options.async; | |
s.defer = scriptObj.options.defer; | |
s.src = scriptObj.url; | |
document.head.appendChild(s); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment