All Projects → alibaba → patchjs

alibaba / patchjs

Licence: MIT License
Patch.js is a incremental (character level) script loader for mobile web.

Website

https://patchjs.github.io/

Our new GitHub repo

https://github.com/patchjs

Key Future

  • simple and easy to use API, like Labjs.

  • support localStorage / Web SQL Database / IndexedDB.

  • real time diff compute through nginx.

  • build diff compute through webpack.

Loader

Reference

<script src="./patchjs-loader/2.0.0/websqldb.js"></script>
<script src="./patchjs-loader/2.0.0/index.js"></script>

API

patchjs.config({
  path: 'http://static.domain.com/path/to/',
  cache: true,
  increment: true,
  version: '0.1.0'
}).load('index.css').load('common.js').wait().load('index.js', function (url, fromCache) {
  // fromCache 
});

More

Service Worker

importScripts('./sw-core.js');

sw.config({
  cacheId: 'cachedb',
  precache: [
    './images/test.png',
    'https://gw.alipayobjects.com/zos/rmsportal/CtJlgAZbmyeSCLxqsgqF.png'
  ],
}).run();

More

Nginx Configure

location /static/ {
    patchjs on;
    patchjs_max_file_size 1024;
}

More

Webpack Configure

var PatchjsWebpackPlugin = require('patchjs-webpack-plugin');

module.exports = {
  plugins: [
    new PatchjsWebpackPlugin({
      increment: true,
      path: 'http://static.domain.com/path/to/'
    })
  ]
};

More

License

Patch.js is MIT licensed.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].