Skip to content

juniorriau/loadCSS

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

loadCSS

A function for loading CSS asynchronously [c]2014 @scottjehl, Filament Group, Inc. Licensed MIT

Usage

Place the loadCSS function inline in the head of your page (it can also be included in an external JavaScript file if preferable).

Then call it by passing it a stylesheet URL:

<head>
...
<script>
  loadCSS( href, before, media ){ ... }
  // load a file
  loadCSS( "path/to/mystylesheet.css" );  
</script>
...
</head>

Optional Arguments

  • By default, your stylesheet will be inserted before the first script tag in the DOM (which may be the one shown above). If you need another insert location, use the optional before argument to specify a different sibling element. The stylesheet will be inserted before the element you specify.

  • You can optionally pass a string to the media argument to set the media="" of the stylesheet - the default value is all.

About

A function for loading CSS asynchronously

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%