addyosmani / addyosmani/critical
How to generate critical css for lots of multiples pages serially?
- Vorherrschende Sprache
- JavaScript
- Sterne
- 10.3k
- Forks
- 390
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Presently this is my gulp task.
```
gulp.task('critical', function (cb) {
var promises = [];
Object.keys(CRITICALCSS.pages).forEach(function(key){
promises.push(critical.generate({
base: '/',
src: CRITICALCSS.base_url + CRITICALCSS.pages[key],
css: [
'dist/assets/css/app.css'
],
styleTarget: 'dist/assets/css/critical/' + key + '.css',
minify: true,
dimensions: [
{ width: 375, height: 1200 },
{ width: 1024, height: 1400 },
{ width: 1280, height: 1500 }
],
ignore: ['@font-face'],
include: [
'.foundation-mq',
'.is-dropdown-submenu'
]
}));
});
return Promise.all(promises)
.then( cb() )
.catch((e) => {
console.error(e.message);
});
});
```
CRITICALCSS is defined in my config.yml
```
# Critical CSS Base URL
CRITICALCSS:
base_url: "http://some-example.com"
pages:
front-page: "/"
page-13: "/?p=13"
page-16: "/?p=16"
fallback: "/?p=1427"
```
When I watch my access log with `tail -f log_file_name` I notice that all the 4 pages are called in parallel.
I would want them to run serially or at-least 1 at a time (order does not matter).
Any thoughts on what I could do to achieve this? My `CRITICALCSS.pages` will grow a lot later. Running this in parallel might not be possible due to memory constraints.
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.