Hello everyone! On the eve of 2025, I would like to congratulate everyone on this holiday! A lot has happened this year. In this article, I would like to summarize the work that I have done during this time.
In the comments, you can also share your achievements! It will be interesting to read!
Cample.js
One of my main goals in 2024 was to improve the framework to one of the fastest on the web using reactivity without a virtual DOM. By the end of 2023, the framework's metrics were at 1.12. This was a pretty good result, but anyway it was slow for me, which is just bad.
Anyway, after half a year or so, I was finally able to finish the implementation. Yes, it took a long time, of course, I couldn't figure it out in so much time. In fact, the solutions seemed trivial on the surface, but it happened as it happened. Somewhere around summer, I was able to finish it to a cool result in 1.08.
After that, we can say that the task was completed. Yes, you can already speed it up to 1.05, if you sit there a little longer over the speed, but it doesn't make much sense, since the main solution already exists.
After that, at the moment I had a little emptiness in my soul, since I had already done what I wanted and needed a new meaning, so I thought about a new idea that could be implemented. And the best continuation of the framework, in my opinion, was:
HMPL
By that time I had already clearly understood that there was no particular point in developing the framework, because the functionality that modern UI tools have is simply colossal, but I didn’t want to lose the developments of fast rendering either, so it was decided to create a symbiosis between the old framework, its extended markup and work with the server.
Look for yourself, there is such a working markup, which can be useful in work, but within the framework it simply does not work:
<div class="tableComponent">
<h1>Data table:</h1>
<table class="table table-hover table-striped test-data">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Material</th>
<th>Quantity in stock</th>
<th>Number of sales</th>
<th>Price</th>
</tr>
</thead>
<tbody id="tbody"><template data-cample-import="{{{tableData}}}" data-cample="data-table"></template></tbody>
</table>
<div class="navigation">
<form class="searchForm">
<input placeholder="Enter the name..." class="searchInput" value="{{data.currentSearchQuery}}" name="taskText" type="text" />
<input type="submit" value="Search" />
</form>
<div class="pagination">
<button :click="{{updateDataFromPagination(data.actionPrevious)}}" class="paginationButton previousButton">
<< /button>
<span class="currentPage">{{data.currentPage}}</span>
<button :click="{{updateDataFromPagination(data.actionNext)}}" class="paginationButton nextButton">></button>
</div>
</div>
</div>
I didn't want to waste so much time spent on the framework + the idea of SSR was already actively developing and developing, that it would be stupid of me not to combine these two parameters into something more worthwhile. Which does not create an architecture, but only complements. This is exactly what the first version of HMPL was.
After working for several months, the first version of HMPL was released, which was also called cample-html. It was the same as what I had done before, but only in the context of working with the server. It looked like this:
const templateFn = CampleHTML.createTemplate(
`<template data-cample data-src="/api/test" data-method="get"></template>`
);
// (After the response arrives from the server) { element = template (HTMLTemplateElement type), status = 200 }
const elementObj = templateFn({
credentials: "same-origin",
get: (prop, value) => {
if (prop === "element") {
console.log(value);
}
},
});
It already looked more or less like it is now, but back then it was more of a beta test. There were a lot of unfinished business that prevented normal use of this module. Plus the name is long and terrible, so a lot had to be changed.
Now, six months later, we can already say that it is quite possible to use it. A lot of cool functionality has been implemented, such as memoization, events, auto body for forms and much more, but the main part of the work has not yet been done. I see that it is possible to make a request interval, add support for web sockets, and also implement a couple more things that are in the plans.
So far, the following has been implemented for the project:
import { compile } from "hmpl-js";
const templateFn = compile(
`<div>
<form onsubmit="function prevent(e){e.preventDefault();};return prevent(event);" id="form">
<div class="form-example">
<label for="login">Login: </label>
<input type="login" name="login" id="login" required />
</div>
<div class="form-example">
<input type="submit" value="Register!" />
</div>
</form>
<p>
{
{
src: "/api/register",
after: "submit:#form",
repeat: false,
indicators: [
{
trigger: "pending",
content: "<p>Loading...</p>"
}
]
}
}
</p>
</div>`
);
const initFn = (ctx) => {
const event = ctx.request.event;
return {
body: new FormData(event.target, event.submitter),
credentials: "same-origin"
};
};
const obj = templateFn(initFn);
const wrapper = document.getElementById("wrapper");
wrapper.appendChild(obj.response);
In my opinion, this looks really promising and such functionality can help many people in creating a cool website.
Conclusion
This year, we could have done more, added functionality, improved bugs, etc., but I think that in 2025, hopefully, it will be better with all this.
Here are the results. I think that super little has been done, but that's how it turned out. How are things going for you? It would be interesting to read.
Thank you all for reading the article! I hope that everything will be fine for you and all your dreams will come true in the new year, the code will be clean, and bugs will be rare!
Top comments (1)
I also wish everyone good luck and good health!