stylesheet-inject
1.2.2 • Public • Published stylesheet-inject
Dynamically load CSS snippets and stylesheets at browser runtime. Standalone utility (no dependencies)
Install
npm install -S stylesheet-inject
or use the CDN version.
Examples
Load remote stylesheet
NPM
var loadCss = require('stylesheet-inject').load;
loadCss('//example.com/path/to/resource.css', function (error, $link) {
});
CDN
<script src="//unpkg.com/stylesheet-inject/dist/stylesheet-inject.min.js"></script>
<script>
var loadCss = stylesheetInject.load;
loadCss('//example.com/path/to/resource.css', function (error, $link) {
});
</script>
Inject raw CSS
NPM
var injectCss = require('stylesheet-inject').inject;
injectCss(
'p { color: red; }' +
'a { color: blue; }'
);
CDN
<script src="//unpkg.com/stylesheet-inject/dist/stylesheet-inject.min.js"></script>
<script>
var loadCss = stylesheetInject.inject;
injectCss(
'p { color: red; }' +
'a { color: blue; }'
);
</script>
Versions
Current Tags
- VersionDownloads (Last 7 Days)
- 1.2.2
1
Version History
Package Sidebar
Install
Weekly Downloads