npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

browserify-common-prelude

0.5.4 • Public • Published

browserify-common-prelude

installation

npm i --save browserify-common-prelude

usage

Better use with factor-bundle (gulp plugin). Best thing of it is that let you add async defer attributes to script tags and prevent block HTML downloading.

// build.js
// ...
var bcp = fs.readFileSync(require.resolve('browserify-common-prelude/dist/bcp.min.js'), 'utf-8');
browserify({
    prelude: bcp
})
.require('jquery')
.require('bluebird')
.bundle()
.pipe(fs.createWriteStream('./global.js'));
 
browserify({
    prelude: bcp
})
.require('chart.js')
.require('moment')
.bundle()
.pipe(fs.createWriteStream('./account.js'));
 
browserify({
    prelude: bcp
})
.add('./a.js')
.external(['jquery', 'bluebird'])
.bundle()
.pipe(fs.createWriteStream('./a.bundle.js'));
 
browserify({
    prelude: bcp
})
.add('./b.js')
.external(['jquery', 'bluebird', 'chart.js', 'moment'])
.bundle()
.pipe(fs.createWriteStream('./b.bundle.js'));
<!doctype html>
<!-- a.html - only one common lib, data-common attribute could be omitted -->
<script src="/global.js" async defer></script>
<script src="/a.bundle.js" async defer></script>
<!doctype html>
<!-- b.html - script tags with data-common attribute must be one after another, no other tags in between -->
<script src="/global.js" data-common async defer></script>
<script src="/account.js" data-common async defer></script>
<script src="/b.bundle.js" async defer></script>

install

npm i browserify-common-prelude

Downloadsweekly downloads

4

version

0.5.4

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability