Created
March 10, 2023 11:25
-
-
Save joekolade/8876b4b6bb150a3c1ac2ca1c0378c297 to your computer and use it in GitHub Desktop.
[JS load SVG sprite]
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
| // @see https://css-tricks.com/ajaxing-svg-sprite/ | |
| var ajax = new XMLHttpRequest(); | |
| ajax.open("GET", "svg/sprite.svg", true); | |
| ajax.send(); | |
| ajax.onload = function(e) { | |
| var div = document.createElement("div"); | |
| div.innerHTML = ajax.responseText; | |
| document.body.insertBefore(div, document.body.childNodes[0]); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment