Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dsheiko/asynccss
⛔️ [DEPRECATED] A function for asynchronous loading of non-critical CSS and deferring Web Fonts, which leverages localStorage for caching.
https://github.com/dsheiko/asynccss
css deprecated loaders obsolete
Last synced: about 1 month ago
JSON representation
⛔️ [DEPRECATED] A function for asynchronous loading of non-critical CSS and deferring Web Fonts, which leverages localStorage for caching.
- Host: GitHub
- URL: https://github.com/dsheiko/asynccss
- Owner: dsheiko
- Created: 2014-11-28T16:45:08.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2021-05-07T10:04:06.000Z (over 3 years ago)
- Last Synced: 2024-11-09T11:53:00.291Z (about 2 months ago)
- Topics: css, deprecated, loaders, obsolete
- Language: JavaScript
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AsyncCSS
[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)
> WARNING - THIS PROJECT IS NO LONGER MAINTAINED!!!
[![NPM](https://nodei.co/npm/asynccss.png)](https://nodei.co/npm/asynccss/)
[![Build Status](https://travis-ci.org/dsheiko/asynccss.png)](https://travis-ci.org/dsheiko/asynccss)
[![Bower version](https://badge.fury.io/bo/asynccss.svg)](http://badge.fury.io/bo/asynccss)A function for asynchronous loading of non-critical CSS and deferring Web Fonts,
which leverages localStorage for caching. When a new version of file supplied (app.css?v2) any old versions (app.css?xx)
are being removed from localStorage automaticallyThis work heavily influenced by
* [Breaking news at 1000ms, Patrick Hamann, The Guardian](https://speakerdeck.com/patrickhamann/breaking-news-at-1000ms-front-trends-2014)
* [BBC News team optimization experiments](https://github.com/BBC-News)
* [Improving Smashing Magazine’s Performance: A Case Study](http://www.smashingmagazine.com/2014/09/08/improving-smashing-magazine-performance-case-study/)Licensed MIT
## Install
With npm do:
```
npm install asynccss --save
```
With bower do:
```
bower install asynccss --save
```## Usage
```js
asyncCss( [ path, .. ], options? );options:
{Boolean} [debug="false"] - is verbose mode? (tells what it does in the console log)
{String} [ns="css_cache_"] - namespace per asyncCss call. If you reuse asyncCss later in your JavaScript,
supply a different `ns`. That will prevent the garbage collector from cleaning up items cached in a previous call.
{Function} [done=function(){}] - callback function
```## Example
``` html
...
(function(){
<?php include ".../asyncCss.min.js"; ?>
try {
asyncCss( [ "css/foo.css", "css/bar.css" ], { debug: true } );
} catch( e ) {
console.log( "asyncCss: exception " + e );
}
}());...
```
## Run automated-tests
```
$grunt mocha_phantomjs
```## Changelog
* 0.0.5 - Garbage collector now removes only old version of a concrete supplied css file.
* 0.0.4 - Automated tests supplied
* 0.0.3 - A separate cache namespace can be supplied now per asyncCss call
* 0.0.2 - Hotfix: missing early exit was causing async loading even after CSS is present in the cache
* 0.0.1 - First commit[![Analytics](https://ga-beacon.appspot.com/UA-1150677-13/dsheiko/asynccss)](http://githalytics.com/dsheiko/asynccss)
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/dsheiko/asynccss/trend.png)](https://bitdeli.com/free "Bitdeli Badge")