Created
January 15, 2020 21:45
-
-
Save frnkst/5e807ce7154dded771bf9c490b4383c5 to your computer and use it in GitHub Desktop.
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
# ccsjson from https://github.com/aramk/CSSJSON | |
# file index.html | |
<html> | |
<head> | |
<link rel="stylesheet" href="style.css" type="text/css" /> | |
<script src="cssjson.js"></script> | |
<script> | |
const xhr = new XMLHttpRequest(); | |
xhr.open("GET", "style.css", true); | |
xhr.onload = function(e) { | |
if (xhr.readyState === 4 && xhr.status == 200) { | |
const styleSheetRaw = xhr.responseText; | |
console.log(styleSheetRaw); | |
const styleSheet = CSSJSON.toJSON(styleSheetRaw); | |
console.log(styleSheet); | |
} else { | |
console.error(xhr.statusText); | |
} | |
}; | |
xhr.onerror = function(e) { | |
console.error(xhr.statusText); | |
}; | |
xhr.send(); | |
</script> | |
</head> | |
<div class="title"> | |
Title | |
</div> | |
</html> | |
# file style.css | |
.title { | |
color: blue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment