question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Confusing Returnings of Server Side Rendering API

See original GitHub issue

Description

Expected SSR generates a rendered (styles included) HTML content. But it seems that it only parses the html and outputs the generated CSS.

confusing returnings:

  1. html in the output is the same as the input one and useless.
  2. stylesCss should contain color variables used in HTML.
  3. colorsCss is always about 20 kb in size without any tree-shaking, no matter what the input is.
  4. colorsMetaContent is useless, I don’t know in which case it will be used.

That is, developers need to inject the uncompleted (without color variables) or unused (too many color variables) CSS into HTML manually, which is not good for DX and performance.

BTW, the SSR example on the document is outdated.

Reproduction

Run the test on StackBlitz

import { render } from "@master/css/render";
import { StyleSheet, Style } from "@master/css";

const target: string[] = [
    `<div class="p:12"></div>`,
    `<div class="font:24 font:56@2xl font:48@lg font:32@md bg:blue-54:hover bg:blue-47 bg:blue-68:active color:orange"></div>`,
];

for (const html of target) {
    test(html);
}

function test(html: string) {
    const key = `render \x1b[93m${html}\x1b[m`;

    console.time(key);
    const result = render(html, { StyleSheet, Style });
    console.timeEnd(key);

    console.log("html:", `\x1b[92m${result.html}\x1b[m`);
    console.log("stylesCss:", `\x1b[96m${result.stylesCss}\x1b[m`);
    console.log("colorsMetaContent:", `\x1b[94m${result.colorsMetaContent}\x1b[m`);
    console.log("length of colorsCss:", `\x1b[95m${result.colorsCss.length}\x1b[m`);
}

System Informations

@master/css: 1.17.2

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
1aroncommented, May 31, 2022

@JacobLinCool I think we might go with your idea - the preset will map colors and inline the rgb into CSS rules, for a minimal output.

Thx again. 😌

1reaction
1aroncommented, May 27, 2022

@JacobLinCool This issue has been sorted into milestone. 😌 https://github.com/master-co/css/milestone/1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server Side Rendering (SSR) vs. Client Side Rendering (CSR ...
Client Side Rendering means generating the HTML components on the browser side, by executing Javascript code within the browser that ...
Read more >
Client-Side Rendering vs Server-Side Rendering vs Static ...
In this article, we discuss the pros and cons of client-side rendering (CSR), server-side rendering (SSR) and static-site generation (SSG).
Read more >
Aurelia Server Side Rendering - Avoid unnecessary client ...
I have an Aurelia application based on Aurelia CLI 1.2.x and Webpack 4, and using Server Side Rendering because search engine indexation is ......
Read more >
What advantages are conferred by using server-side page ...
Client -side HTML rendering: Lower bandwidth usage; Slower initial page render. May not even be noticeable in modern desktop browsers.
Read more >
Server-Side Rendering (SSR) Vs Client-Side Rendering (CSR)
Clear separation of the concerns between the client and the server; you can easily build new clients for different platforms (e.g. mobile, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found