Skip to content

Wikunia/fast-mustache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fast Mustache

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.

How it works?

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.

Why?

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're rich?

You don't need a second yacht and have some coins to spend? Here I am :)

Flattr this git repo

Contributing

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.

How to contribute?

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
    • I am using QUnit which is a testing framework used by jQuery
    • All the testing files are inside the QUnit folder
    • Current state:
      • only the diff algorithm has tests. Any idea how to test the Diff.toHTML function?
  • 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 running gulp

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.

Next steps

  • Provide a better example
    • Diff.toHTML has some empty ifs
  • Measure how fast it actually is
  • Sometimes it's better to render everything, but when?
  • Improve the diff algorithm

About

Render only the differences

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages