So many of us are using MustacheJS which is a great template implementation. But how often do you really need to render your whole page?
Normally you will build your own system which will render only the partials that changed. It should be possible to do this automatically!
This project tries to make this dream come true. The current state is only the very beginning but I am a fan of shipping ASAP.
The idea is to get the whole website or well a part of it using a post/get request. PHP has no idea how many information the user already sees, therefore the script will return everything. Now Fast Mustache will check whether a cache exists and if that is the case it will generate a diff, which is basically an object which represents all the changes. Afterwards jQuery will use this diff to render only the differences.
The DOM is slow! For example React uses a virtual DOM which kind of does the same thing. If you don't want to change your whole code you probably don't want to use React.
You don't need a second yacht and have some coins to spend? Here I am :)
At the moment this is the most important section. You are interested in this project? Feel free to write me an email, create an issue or a pull request.
I have a lot of repos here at GitHub but never worked on such big project. A few things that I believe are important:
- Testing
- Example
- There is an
example/folder which is more or less generated by Gulp - All files inside the
js/folder will be minified and the logs will be removed, when runninggulp
- There is an
One important things:
Unfortunately I changed the mustache.js file so it isn't possible to use an existing implementation :/
I've added the function
mustache.setCache = function setCache (name,value) {
return defaultWriter.cache[name] = value;
};
if you have an idea how to get rid of it, please open an issue!
If you change a file inside the js/ folder make sure, that QUnit and Gulp have no errors.
- Provide a better example
Diff.toHTMLhas some empty ifs
- Measure how fast it actually is
- Sometimes it's better to render everything, but when?
- Improve the diff algorithm
