Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

css-injector

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-injector

Creates stylesheets out of strings

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

css-injector

Creates stylesheets out of strings

Motivation

Bakes one or more baseline mandatory stylesheets into your JavaScript -- i.e., without having to depend on an external .css file. You supply css rules as strings and cssInjector creates <style>...</style> elements and inserts them into your <head>...</head> element (wherever else you want).

Synopsis

cssInjector(stylesheet [ , id [ , refereneceElement ] ] );

where:

  • stylesheet is a string or a list of strings containing css rules.
  • id is an optional string that will get assigned to the <style> tag's id attribute
  • referenceElement is an optional DOM Element or a string containing a css selector that resolves to a DOM element or null. Including this parameter forces the new <style>...</style> element to be inserted just before the given element. If omitted (or undefined), the new stylesheet is injected at top of <head>...</head> element. If null, it is inserted at the bottom of the <head>...</head> element.

Example

var stylesheet = [
    'div {',
    '    background-color: red;',
    '    color: yellow;'
    '}'
];

cssInjector(stylesheet);

[See the note Regarding submodules for important information on cloning this repo or re-purposing its build template.]

API documentation

Detailed API docs can be found here.

FAQs

Package last updated on 17 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc