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

fg-loadcss

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fg-loadcss - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

onloadCSS.js

2

bower.json
{
"name": "loadcss",
"version": "0.1.5",
"version": "0.1.6",
"main": [

@@ -5,0 +5,0 @@ "loadCSS.js"

@@ -22,5 +22,7 @@ /*!

ss.media = "only x";
// DEPRECATED
if( callback ) {
ss.onload = callback;
}
// inject link

@@ -30,6 +32,6 @@ ref.parentNode.insertBefore( ss, ref );

// It is designed to poll until document.styleSheets includes the new sheet.
function toggleMedia(){
ss.onloadcssdefined = function( cb ){
var defined;
for( var i = 0; i < sheets.length; i++ ){
if( sheets[ i ].href && sheets[ i ].href.indexOf( ss.href ) > -1 ){
if( sheets[ i ].href && sheets[ i ].href.indexOf( href ) > -1 ){
defined = true;

@@ -39,10 +41,14 @@ }

if( defined ){
ss.media = media || "all";
cb();
}
else {
setTimeout( toggleMedia );
setTimeout(function() {
ss.onloadcssdefined( cb );
});
}
}
toggleMedia();
};
ss.onloadcssdefined(function() {
ss.media = media || "all";
});
return ss;
}
}
{
"name": "fg-loadcss",
"version": "0.1.5",
"version": "0.1.6",
"description": "A function for loading CSS asynchronously",

@@ -5,0 +5,0 @@ "main": "loadCSS.js",

@@ -32,3 +32,15 @@ # loadCSS

#### Using with `onload`
Include [`onloadCSS` function](https://github.com/filamentgroup/loadCSS/blob/master/onloadCSS.js) on your page.
``` javascript
function onloadCSS( ss, callback ){ ... }
var stylesheet = loadCSS( "path/to/mystylesheet.css" );
onloadCSS( stylesheet, function() {
console.log( "Stylesheet has asynchronously loaded." );
});
```
#### Contributions and bug fixes

@@ -35,0 +47,0 @@

Sorry, the diff of this file is not supported yet

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