This library currently implements small part of Facebook BigPipe so far, but the advantage is to efficiently insert/replace content and work with the DOM. It is also possible to easily call JavaScript modules from PHP.
npm install bigpipe-utilThis library currently implements small part of [Facebook BigPipe][blog] so far, but the advantage is to efficiently insert/replace content and work with the DOM. It is also possible to easily call JavaScript modules from PHP.
shell
$ composer require richarddobron/bigpipe
`$3
`shell
$ npm install bigpipe-util
`$3
`javascript
import Primer from 'bigpipe-util/src/Primer';Primer();
window.require = (modulePath) => {
return modulePath.startsWith('bigpipe-util/')
? require('bigpipe-util/' + modulePath.substring(13) + '.js').default
: require('./' + modulePath).default;
};
`$3
`html
`π Request API
`javascript
import AsyncRequest from 'bigpipe-util/src/AsyncRequest';const request = (new AsyncRequest('/ajax/remove.php'))
// or .setURI('/ajax/remove.php')
.setMethod('POST')
.setData({
param: 'value',
})
.setInitialHandler(() => {
// pre-request callback function
})
.setHandler((jsonResponse) => {
// A function to be called if the request succeeds
})
.setErrorHandler((xhr) => {
// A function to be called if the request fails
})
.setFinallyHandler((xhr) => {
// after request callback function
})
.send();
if (OH_NOES_WE_NEED_TO_CANCEL_RIGHT_NOW_OR_ELSE) {
request.abort();
}
`β‘οΈ What all can be Ajaxifed?
π Links
`html
ajaxify="/ajax/remove.php"
rel="async">Remove Item
`π Forms
`html
method="POST"
rel="async">
`π¬ Dialogs
`html
ajaxify="/ajax/modal.php"
rel="dialog">Open Modal
``BigPipe is inspired by Facebook's BigPipe. For more details
read their blog post: [Pipelining web pages for high performance][blog].
There is a large number of PHP projects for which moving to modern frameworks like Laravel Livewire, React, Vue.js (and many more!) could be very challenging.
The purpose of this library is to rapidly reduce the continuously repetitive code to work with the DOM and improve the communication barrier between PHP and JavaScript.
We welcome contributions! If you'd like to help improve this project, feel free to open an issue or submit a pull request.
The MIT License (MIT). Please see License File for more information.
[blog]: https://www.facebook.com/notes/facebook-engineering/bigpipe-pipelining-web-pages-for-high-performance/389414033919