0

I am having the issue the javascript is loaded before the page contents are loaded so decided to use the gulp-defer package in my gulptask.

Here is the code

// including plugins
var gulp = require('gulp')
    defer = require("gulp-defer");

// task
gulp.task('concat', function () {
    gulp.src('./javascript/*.js') // path to your files
    .pipe(concat('concat.js'))  // concat and name it "concat.js"
    .pipe(gulp.dest('./dest'));
});
gulp.task('html:release', function() {
  return gulp.src('./index.html')
   .pipe(defer())                  //defer method is called 
   .pipe(gulp.dest('./dest'));
});

I referred this from gulp-defer package.actually I cant able to understand how it is processed.Please any one explain how is the defer works in gulp task. Thanks in advance!!

Ramyachinna
  • 413
  • 1
  • 8
  • 20

1 Answers1

0

Not sure what you are asking for but the documentation is self-explained:

Moves render blocking javascript and css into a deferred loading section.

It is likely to be helpful if you get "Eliminate render-blocking JavaScript and CSS in above-the-fold content" warning from PageSpeed Insights results

https://www.npmjs.com/package/gulp-defer

Hung Cao
  • 3,130
  • 3
  • 20
  • 29