5 ms·
Nope. You define your page with custom html tags that won't even render properly without Javascript. And then you need Javascript for literally everything: ini
by dmitriid 7y ago
Nope.
You define your page with custom html tags that won't even render properly without Javascript. And then you need Javascript for literally everything: initialising the component, data fetching, inserting data into the DOM, updating data in the DOM etc.
- nickthemagicman 7y agoWhen I used SPA's it was basically web components inside of javascript so seemed like a layer of unnecessary indirection? I'm SURE web components allow a non-js fallback, or that should be introduced into the spec. See here for progressive enhancement of web components https://googlechromelabs.github.io/howto-components/howto-tabs/ https://googlechromelabs.github.io/howto-components/howto-ta... Dont' SPA's require defining multiple components? A non-js component inside of the html page and a JSX component or whatever inside of the SPA.
- dmitriid 7y ago> When I used SPA's it was basically web components inside of javascript so seemed like a layer of unnecessary indirection? In vast majority of cases it's nowhere near "basically web components". > I'm SURE web components allow a non-js fallback, or that should be introduced into the spec. They don't. All they can do is render static content inside if they have any. > See here for progressive enhancement of web components I fail to see where you see progressive enhancement. It's literally dozens of lines of Javascript code. If you disable JS on that page, you'll get just the static content with no functionality. > Dont' SPA's require defining multiple components? A non-js component inside of the html page and a JSX component or whatever inside of the SPA All you do is attach the root node of an SPA to any element in the DOM. A common approach would be: <body> <div id="app"></div> </body> // elsewhere in JS code X.render(document.getElementById('app'), rootNode) where X is your framework of choice.
- Spivak 7y ago> They don't. All they can do is render static content inside if they have any. What would a non-JS fallback look like that isn't this? Where would the functionality come from if not JS?
- dmitriid 7y agoNot just functionality. Even the styles are broken if you disable JS. That's not "graceful degradation". It's full loss of functionality. Whereas graceful degradation is Graceful degradation is the ability of a computer, machine, electronic system or network to maintain limited functionality even when a large portion of it has been destroyed or rendered inoperative. However, I was primarily responding to "javascript exists for animation and data fetching". As you clearly see, it exists for way more than just that.
- nickthemagicman 7y ago> Even the styles are broken if you disable JS. This is outright false "If JavaScript does not run, the element will not match :defined. In that case this style adds spacing between tabs and previous panel." https://googlechromelabs.github.io/howto-components/howto-tabs/ https://googlechromelabs.github.io/howto-components/howto-ta... The styles still run....
- svieira 7y agoThe styles defined _in_ the web component do not though (none of the `flex` styles are there). If the component was any more complicated than a pair of `<slot />` elements then the DOM structure would also completely change (and any ::part and ::theme targets would be gone too). When JS is disabled you are left with a bunch of arbitrary tags in a structure that doesn't match the structure they have when JS is enabled. That said, I don't think there's a good answer to this problem. Components-as-macros would run without JS, but then you have the LISP problem with composing macros (maybe this is a solved problem, but I haven't read Common Lisp's spec or used Racket in anger).
- nickthemagicman 7y ago>In vast majority of cases it's nowhere near "basically web components". What else does it do besides render JSX components and manage their state just like a web component except with more indirection? > All you do is attach the root node of an SPA to any element in the DOM. You missed the point of what I was saying The root node is a single node...where do you define the rest of your components? IN JAVASCRIPT. IF you want progressive enhancement you have to define a SECOND SET OF NODES IN HTML. THIS IS REDUNDANT. >I fail to see where you see progressive enhancement. Why don't you actually read the thing? "If JavaScript is disabled, all panels are shown interleaved with the respective tabs. The tabs now function as headings."
- dmitriid 7y ago> What else does it do besides render JSX components and manage their state just like a web component except with more indirection? 1. There many more ways to implement SPA than JSX. 2. WebComponents have exactly zero state management capabilities, and you need to implement your own ways to deal with state So, SPA frameworks provide the following: - state management - optimised/batched updates (they can flush to the DOM efficiently thus avoiding jank, unnecessary re-paints and reflows) - async rendering - easy fallback states for async data fetching - data fetching - data propagation (for example, from parent to a deeply nested child) - data binding - render targets other than HTML (example, canvas, webgl, native mobile apps) I'm definitely missing more. None of the above are provided by web components, and you will need to bring your own frameworks/libs to cover all those points.
- nickthemagicman 7y agoSome of those aren't SPA specific. They're just javascript. Some are done by external libraries like redux. Some are benefits, however, two way data flow is a janky model in itself that could possbily be done away with by a nice data structure imo. Also, this SPA cargo cult has been around a lot longer than Web Components which have just the past year or two become cross browser compatible. I expect great things from them. Web Components and their associated libraries can and will do all of those as they grow.
- Spivak 7y agoIt seems odd to rail against custom HTML tags requiring code to drive them. Unless you want custom tags to basically just be text-replacement macros for built-in elements you're gonna need some code somewhere to actually make them work. In a parallel universe where web components came first the built-in tags would themselves be web components backed by JS instead of having native implementations.
- dmitriid 7y agoI was primarily responding to "javascript exists for animation and data fetching". Javascript is the core of WebComponents for better or for worse.
- nickthemagicman 7y agoNot accurate at all. Native Web Components are a core spec in the BROWSER. A web component can be completely styled and created without Javascript.
- dmitriid 7y agoANd what would be the purpose of such a web component? ;)
- nickthemagicman 7y agoProgressive Enhancement...
- e12e 7y ago> You define your page with custom html tags that won't even render properly without Javascript. html5 encourages custom tags, and can be styled with plain CSS?