1. insert-css
insert a string of css into the <head>
insert-css
Package: insert-css
Created by: substack
Last modified: Fri, 18 Nov 2022 08:03:12 GMT
Version: 2.0.0
License: MIT
Downloads: 869,250
Repository: https://github.com/substack/insert-css

Install

npm install insert-css
yarn add insert-css

insert-css

insert a string of css into the <head>

browser support

example

     var insertCss = require('insert-css');
    var styleElement = insertCss('body { background:blue; }');

api

     var insertCss = require('insert-css');

var styleElement = insertCss(css, opts);

Insert some CSS into the page.

  • opts.container - Which HTMLElement to use as the base mounting point, defaults to
    document.querySelector('head').

  • opts.prepend - Add the CSS at the top level of the container instead of at the bottom level (default).

This is particullary useful for library creators where you may want your default CSS to be prepended so it
can be easily overriden by user styles.

development

example

 npm run example

test

 npm test

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code