Created
November 14, 2012 22:09
-
-
Save Raynos/4075196 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
var Module = require("thirdparty") | |
var instance = Module(...) | |
// instance damn better well be a DOM element | |
// We already injected the relevant style so it's save to inject it into the DOM | |
// and it will be styled immediately | |
document.body.appendChild(instance) | |
// If this was a naughty thing it's ok because we prefixed the selectors | |
// So the naughty css only applies to the children of the prefix | |
instance.className = "thirdparty-container") | |
document.body.appendChild(instance) |
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
<html> | |
<head> | |
<script src="bundled/head.js"></script> | |
</head> | |
<body> | |
<script src="bundled/body.js"></script> | |
</body> | |
</html> |
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
// A string containing css | |
var css = require("thirdparty/css/standard.css") | |
, ownCss = require("./css/style.css") | |
, Sheet = require("style-sheet") | |
, rework = require("rework") | |
// Sheet(String) returns a <style>string inlined</style> element | |
var sheet = Sheet(css) | |
, mySheet = Sheet(ownCss) | |
document.head.appendChild(sheet) | |
document.head.appendChild(mySheet) | |
// or prefix naughty third party css | |
// rework is a library to do prefixing selectors | |
var css = rework(require("thirdparty/css/naughty.css")) | |
.use(rework.prefixSelector(".thirdparty-container")) | |
.toString() | |
var sheet = Sheet(css) | |
document.head.appendChild(sheet) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment