Z
Z
ZaxapKramer2016-08-09 20:43:28
JavaScript
ZaxapKramer, 2016-08-09 20:43:28

Can you recommend a Javascript micro template engine (client-side)?

Hello! There was this kind of problem.
I write a site for several pages for the soul (in my spare time). It is arranged simply: data in json is transferred to html (also sometimes "subordinate" pieces of code from template files are loaded into the main file).
At first, everything was pretty good: I found temprites.js interesting and suitable for the task , which I finalized for myself, optimized, fixed jambs. It seemed to satisfy all my needs: layout in html code - data in json, therefore, you can not really hide anything with a terrible display: none, further showing the content, because sometimes you need the text to appear when you click on the button (for example, when you need to load the next pages with results (for example, by scrolling (a la vk) or by the button )).
Problems arose when it became necessary to load first 1 page with content + some_more_lines_of_text unique for each page, and when adding other "pages" (which was done via ajax, for example, by clicking on a button), these lines of text were no longer loaded. Well, or build some more complex structure, where "only html tags" (without marks like {{ title }} and other charms ) were very, very flawed .
I love optimization, in this regard I am very meticulous, so I decided to recoup my creation in full: scripts weigh a minimum (bytes-kilobytes), generation speed is high, it is optimized if possible, etc. - micro-site in its purest form. I think many would say that all this is superfluous (often it is), but looking at how the mother-in-law's phone loads Yandex for 2 minutes (and many people who know the Internet also have problems, and not only on phones), I thought: why should a one-pager (one page on such a site (there are at most 10 pages with some reservations that I mentioned above)) weigh ~ 300kb , if you can keep within ~ 30 ?
Can you suggest what would be the best solution in my case? I repeat: the "site" itself is relativelymicro - minimalism in terms of design and weight.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Pretor DH, 2016-08-09
@ZaxapKramer

I have written my own, they have been working for 10 years (updated a couple of times) ... For I did not find anything compact and optimized ... neither at that time, nor now I see alternatives.
What was written in 10 years is universal and fat like a cat in an oil factory. Moreover, it is written in such a way that if you need to take a step to the side, then nothing will work, only along the "rails" or "the wings will be broken and then only with crutches" ... Or you need to write another 100K of code to the library in 30K to make it work. Whereas mine fits in 10K.
Well, I don’t need to fence a garden of 100 hectares around, let there be freemen.

D
Denis Ineshin, 2016-08-09
@IonDen

iCanHaz.js - compressed 5.5 kb

M
Michael, 2016-08-09
@springimport

Essentially - what about Angular?
In everything you need to observe the measure, it is also called the golden seridine. By the way, your project is no better than Yandex. You veered to the other side. Maybe it will be a discovery for you that you can adjust the compression and the site will load faster. Especially if you do not play the fool and buy yourself a normal Internet.
It is important to write software with good architecture and maintainability, sooner or later everything will come to this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question