Kalabasa / htmz

html with targeted manipulation zones
http://leanrada.com/htmz/
Other
1.73k stars 42 forks source link

Is a no JS website possible with this if put thought some preprocessor (Speculation) #14

Closed mofosyne closed 8 months ago

mofosyne commented 8 months ago

If I understand the snippet correctly, this search and replaces the doc and replace specific sections with a specially formatted iframe.

If that's the case, then in theory it could be possible to add a script to this htmz for static website generators to add some dynamic capabilities to their site (but without having to add JS code to it).

Application for this technique could be for torsites that should really not have javascript enabled.


You still want to keep the snippet as it makes things easier without having to integrate a preprocessor. But basically this would be an extra optional script in this repo that developers can optionally call. It would read a html input and scan for a htmlz snippet (to indicate it is being used) and then do the search and replace of required tags with an iframe) before outputting to stdio

jmcudd commented 8 months ago

The technique used by htmz is likened to the technique used by htmx. Its function and use cases have been extensively documented and written about on htmx.org. I recommend you go read about hypermedia and HATEOAS on htmx.org Essays. Htmz is merely a ultra lightweight implementation without any bells or whistles.

Kalabasa commented 8 months ago

I don't think noJS is possible. But what you're describing as a preprocessor is similar to one of the examples (as a Cloudflare worker): https://github.com/Kalabasa/htmz/blob/eda6e50296b4309665a9792e6c6a8c1d682ec1ce/examples/cf_clean_target_tabs/worker.js

Otherwise, I think you're looking for a HTML templating system?

Jaculabilis commented 8 months ago

In theory, if all you need to do is apply a selector and replace HTML, the browser should be able to do it without going through the JS engine. The only reason htmz needs JS is because the HTML specification doesn't have a keyword for target= that behaves the way htmz does, so it implements that in JS. With enough support, you could probably get that behavior into the HTML specification, and then browsers with JS disabled or lacking a JS engine entirely would have interactive web pages the htmz way.

mofosyne commented 8 months ago

Then perhaps this ticket should be more "How do we get target= behavior updated in the HTML specification"?

Is this where we should post the proposal to?

If so then how do we exactly describe the required changes?

https://github.com/whatwg/html

Kalabasa commented 8 months ago

Yes, it would be whatwg/html.

I think there are two slightly different things being discussed in this thread:

  1. On load, automatically load external HTML into a specified element
  2. On click, load external HTML into a specified element

htmz implements #2 only.

#1 is being proposed in https://github.com/whatwg/html/issues/2791.

A separate proposal is probably better for #2 because it would be simpler. It wouldn't have to deal with render blocking and circular dependency issues as in #1.

Converting this into a Discussion.