1.1.5 • Published 10 years ago

gulp-gotohead v1.1.5

Weekly downloads
1
License
-
Repository
github
Last release
10 years ago

gulp-gotohead

Put into the HEAD of a HTML document snippets of code CSS or Javascript.

Overview

If you care about your website performance, you surely care about CSS and JavaScript minification, probably image optimization too, but what about the rendering of all this, do you care? This Gulp plugin was made to help you with that.

When we separate the code of the visible content from the other it's possible to optimize the speed of rendering of the page, obtaining a gain in the overall performance.

Getting Started

This plugin require Gulp ~3.8.6

npm install --save-dev gulp-gotohead

The "gotohead" task

var gulp = require('gulp');
var gotohead = require('gulp-gotohead');

var styles = ['./public/css/style1.css', './public/css/style2.css'];
var scripts = ['./public/js/script1.js', './public/js/script2.js'];

gulp.task('Styles', function () {
    return gulp.src(styles)
    .pipe(gotohead({orig:'./public/index.html'}));
});
gulp.task('Scripts', ['Styles'], function () {
    return gulp.src(scripts)
    .pipe(gotohead({tag:'script', orig:'./public/index.html'}));
});

gulp.task('JadeStyles', function () {
    return gulp.src(styles)
    .pipe(gotohead({jade: true, orig:'./public/template.jade'}));
});
gulp.task('JadeScripts', ['Styles'], function () {
    return gulp.src(scripts)
    .pipe(gotohead({jade: true, tag:'script', orig:'./public/template.jade'}));
});

gulp.task('gotohead', ['Styles', 'Scripts', 'JadeStyles', 'JadeScripts']);
gulp.task('default', ['gotohead']);

Options

NomeValor
tagString style or script.Default: style
jadeBoolean true or false. Default: false. Used to HTML wrote with Jade.
origString path/to/origin/file.html. Define the path to HTML file.
destString path/to/destiny/file.html. If not defined, will be the same that origin.
separatorString ;Default: \n

Extra

May be you are interested in compress your files before you put it into the HEAD, see an example of code in gulpfile.js.

Licence

MIT

1.1.5

10 years ago

1.1.3

10 years ago

1.0.0

10 years ago

0.9.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago