Socket
Socket
Sign inDemoInstall

fg-loadcss

Package Overview
Dependencies
Maintainers
6
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 2.0.0-2 to 2.0.0-3

2

package.json
{
"name": "fg-loadcss",
"version": "2.0.0-2",
"version": "2.0.0-3",
"description": "A function for loading CSS asynchronously",

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

@@ -24,2 +24,18 @@ /*! loadCSS. [c]2017 Filament Group, Inc. MIT License */

// if preload isn't supported, get an asynchronous load by using a non-matching media attribute
// then change that media back to its intended value on load
rp.bindMediaToggle = function( link, media ){
function enableStylesheet(){
link.media = media;
}
if( link.addEventListener ){
link.addEventListener( "load", enableStylesheet );
} else if( link.attachEvent ){
link.attachEvent( "onload", enableStylesheet );
}
// also enable media after 3 seconds,
// which will catch very old browsers (android 2.x, old firefox) that don't support onload on link
setTimeout( enableStylesheet, 3000 );
};
// loop through link elements in DOM

@@ -37,18 +53,8 @@ rp.poly = function(){

var finalMedia = link.media || "all";
// if preload isn't supported, get an asynchronous load by using a non-matching media attribute
// then change that media back to its intended value on load
var enableStylesheet = function(){
link.media = finalMedia;
}
if( link.addEventListener ){
link.addEventListener( "load", enableStylesheet );
} else if( link.attachEvent ){
link.attachEvent( "onload", enableStylesheet );
}
// bind listeners to toggle media back
rp.bindMediaToggle( link, finalMedia );
// if preload is not supported, kick off an asynchronous request by using a non-matching media query and rel=stylesheet
link.media = "x";
link.rel = "stylesheet";
// set rel=preload to stylesheet after 3 seconds,
// which will catch very old browsers (android 2.x, old firefox) that don't support onload on link
setTimeout( enableStylesheet, 3000 );
// prevent rerunning on link

@@ -55,0 +61,0 @@ link.setAttribute( "data-loadcss", true );

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