Last active
September 10, 2016 16:26
-
-
Save andyyou/082072760cef03befb4e to your computer and use it in GitHub Desktop.
codepen-with-react.js
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
(function() { | |
function runScripts() { | |
var bodyScripts = 'body script:not([src])'; | |
var count = 0; | |
Array.prototype.forEach.call(document.querySelectorAll(bodyScripts), function setJSXType(element) { | |
if (count++ === 0) { | |
var res = ["http://fb.me/react-with-addons-0.11.2.js", "http://fb.me/JSXTransformer-0.11.2.js"]; | |
for (r in res) { | |
var tag = document.createElement('script'); | |
tag.setAttribute('src', res[r]); | |
document.body.insertBefore(tag, element); | |
} | |
} | |
element.setAttribute('type', 'text/jsx'); | |
}); | |
}; | |
if (window.addEventListener) { | |
window.addEventListener('DOMContentLoaded', runScripts, false); | |
} else { | |
window.attachEvent('onload', runScripts); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment