Skip to content

Instantly share code, notes, and snippets.

@andyyou
Last active September 10, 2016 16:26
Show Gist options
  • Save andyyou/082072760cef03befb4e to your computer and use it in GitHub Desktop.
Save andyyou/082072760cef03befb4e to your computer and use it in GitHub Desktop.
codepen-with-react.js
(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