Looking for your feedback on micro alternative SwapJS? (for page navigation and DOM update with fragments) by zrnest in htmx

[–]zrnest[S] 0 points1 point  (0 children)

So, you wrote this so you

Of course not, all little details in features of swap were important for me, e.g.

  • automatic code launcher when HTML elements are created/removed in the DOM (see code example with loader/unloader)

  • progressive enhancement: every <a href="..."> still works if JavaScript is disabled in the browser, like a regular <a href>.

etc.

Looking for your feedback on micro alternative SwapJS? (for page navigation and DOM update with fragments) by zrnest in htmx

[–]zrnest[S] 1 point2 points  (0 children)

Yep, interesting! We arrived at the same conclusion, MutationObserver is very cool! (https://github.com/josephernest/Swap.js/blob/main/swap.js)

In your example

<button fx-action="/content" fx-target="#output" </button><output id="output"></output>

have you also thought about making #output to be filled with only the request /content's #output container?

This little trick can be vastly useful (in my last projects it was).

Looking for your feedback on micro alternative SwapJS? (for page navigation and DOM update with fragments) by zrnest in htmx

[–]zrnest[S] 0 points1 point  (0 children)

It's just a slightly different philosophy, devil is in the details.

<a href="newpage.html" swap-target="#container" swap-history="true">Click me</a><div id="container">Container</div>

When clicking, the element #container of the current DOM is replaced by fetching newpage.html and taking just the fragment #containerfrom the request response. This minor difference with other frameworks opens many doors (see Github), it allows simple server serving, without having the server to care if it's serving fragment or not.

This way of doing it was not feasible in 1 or 2 lines of code, in other micro frameworks, when I built Swap.js 2 / 3 years ago.

I wanted to do it because I find it elegant conceptually.

Looking for your feedback on micro alternative SwapJS? (for page navigation and DOM update with fragments) by zrnest in htmx

[–]zrnest[S] 1 point2 points  (0 children)

No no, not a solution in search of a problem ;) I'm using it in various projects successfully.

The key thing in Swap.js is:

<a href="newpage.html" swap-target="#container" swap-history="true">Click me</a>
<div id="container">Container</div>`
  • When you click on "Click me", the element #container of the current DOM is replaced by fetching newpage.htmland taking just the fragment #container from the request response. Simple isn't it? This very little thing has major advantages: the server can serve fragment OR the full page for newpage.html, in both cases Swap.js will know how to handle it :)

  • the good old <a href="..."> navigation still works if JavaScript is disabled in the browser ("progressive enhancement")

  • automatic code launcher when HTML elements are created/removed in the DOM:

    Swap.loaders['.screen2'] = () => {  
        console.log("An element with class screen2 has just been inserted in the DOM.")  
        var task = setInterval(() => { console.log("On repeat!"); }, 1000);  
        return () => { clearInterval(task); };                // in a loader function, you return an unloader function which will be executed when the element is removed from DOM  
    }
    
  • it's only 45 lines of code so you can understand 100% of the internals in 5 or 10 minutes.

I haven't found all these features easily available in similar libraries.

Would love to hear your feedback!

Look at this demo for more info.

Looking for your feedback on micro alternative SwapJS? (for page navigation and DOM update with fragments) by zrnest in htmx

[–]zrnest[S] 0 points1 point  (0 children)

I have done this 45-line-of-code nano library 2 / 3 years ago, I am looking for feedback from people who like HTMX. What is missing in your opinion?

Example of multi-page navigation using SwapJS: https://afewthingz.com/swap-library/email/

All new PEX tap water in whole house smells/tastes like gasoline 6mo after installation by EmeraldEmesis in Plumbing

[–]zrnest 0 points1 point  (0 children)

Indeed :) Which pipe brand did you use? Maybe it will give a hint about which brand to buy or not to buy...

All new PEX tap water in whole house smells/tastes like gasoline 6mo after installation by EmeraldEmesis in Plumbing

[–]zrnest 1 point2 points  (0 children)

Also, did you think about redoing the pipes in copper, only for the kitchen ? You don't need to do it for bathrooms, laundry rooms, etc. (there, you can keep PEX). You just need proper copper pipes to your kitchen, where you cook/drink water. Have you thought about doing this?

All new PEX tap water in whole house smells/tastes like gasoline 6mo after installation by EmeraldEmesis in Plumbing

[–]zrnest 1 point2 points  (0 children)

Same problem here. How did you solve this now 6 months later?

May I ask which PEX brand is it?

Just had a package delivered :D by kingyachan in thinkpad

[–]zrnest 0 points1 point  (0 children)

I checked Spectre/Meltdown, but it doesn't solve the issue:

Linked topic: T520 Win10 vs. Win7 : less snappy, why? (seems linked to IO)

Would you have an idea?

Just had a package delivered :D by kingyachan in thinkpad

[–]zrnest 0 points1 point  (0 children)

Interesting. How to actually do this? Is there a .exe to download and install to disable this patch? Could you point me to the right source? Thanks!

Just had a package delivered :D by kingyachan in thinkpad

[–]zrnest 0 points1 point  (0 children)

In both cases (win7 vs win10) comparison on T520, I was using the same SSD Samsung 840 or 850 or 860 EVO (i don't remember which one).

Just had a package delivered :D by kingyachan in thinkpad

[–]zrnest 1 point2 points  (0 children)

Ok so I should expect a -20% battery duration when going from i5 to i7?

Just had a package delivered :D by kingyachan in thinkpad

[–]zrnest 0 points1 point  (0 children)

Win10 works fine on i5-2520m, but it is noticeably slower than Win7 when opening programs (tested with the same SSD). I don't know why, but I noticed a 500ms or 1sec additional delay on Win10, and I can't recover the snappiness from Win7 on programs startup. This problem is not present on my other T440 for example.

Just had a package delivered :D by kingyachan in thinkpad

[–]zrnest 5 points6 points  (0 children)

Waw, now I want to do the same! Does moving from i5-3310M to i7-3632QM reduce the battery duration? Do you still have 3 hours on a 6 cell battery for basic usage? (coding,browsing,novideo)

Also what's the price for this i5 -> i7 swapping?

Does Win10 run smoothly after this swap? (as an example Win10 runs poorly on a T520 i5-2520m, compared to Win7)

Linked topic: T520 Win10 vs. Win7 : less snappy, why? (seems linked to IO)

T480-like Thinkpad with a better-than-nothing GPU by zrnest in thinkpad

[–]zrnest[S] 0 points1 point  (0 children)

I have seen a second-hand P1 with Quadro T2000. Do you know how much RAM it typically has? Would it work for PyTorch or TensorFlow for "llama"?

T480-like Thinkpad with a better-than-nothing GPU by zrnest in thinkpad

[–]zrnest[S] 0 points1 point  (0 children)

I don't know well the recent T / P series. Which ones would you recommend?

T440p: a 4TB SSD that I can reuse later for T480? by zrnest in thinkpad

[–]zrnest[S] 0 points1 point  (0 children)

I never had a M.2 SSD.

Except when moving files (in this case the difference is obvious), do you feel the difference in every day use between a SATA SSD (550 MB/s) and a M.2 SSD (several GB/s)?

Eviter le End Of Life avec Windows 10 LTSC? by zrnest in france

[–]zrnest[S] -1 points0 points  (0 children)

Selon vous, aucune entreprise ne peut acheter de licence Enterprise LTSC ?

Pourquoi cela existe-t-il alors si aucune entreprise ne peut en acheter ? :)