Code Monkey home page Code Monkey logo

Comments (6)

developit avatar developit commented on June 9, 2024 2

@alan-agius4 I think we could use this request as an interesting use-case for the plugin API @janicklas-ralph has been noodling on. It's mainly aimed at additional HTML tree reduction, but it should be possible to have it also support marking nodes as "do not mutate".

from critters.

janicklas-ralph avatar janicklas-ralph commented on June 9, 2024

Can you give me some more context on when you would have lazy loaded CSS?
It would seem easier to just let critters make that change

from critters.

alan-agius4 avatar alan-agius4 commented on June 9, 2024

Hi @janicklas-ralph,

Our main use-cases are typically when the same HTML document is transformed multiple times. The reasons for the multiple transformations is because the index file is used for different cases in the same application.

  • App shell + SSR/Prerendering
    We run critters on the index.html, which contains the application shell during build time. This same document is used as the HTML document for the SSR'd page. While when doing SSR the app-shell is redundant, there are cases were users would want to selectively select pages to SSR or have a PWA togather with SSR, where the app-shell would be used when in offline mode to enhance the FCP. In this case critters will essentially be run twice on the same document, once when generating the app-shell and another time when handling the SSR request.

  • CSS Async + SSR/Prerendering
    Similar to the above, the same HTML page is used for SSR'd and non SSR'd pages. In most cases JavaScript bundles will take a longer time to download, parse and for the application to bootstrap and start rendering the first component thus the chance of having FOUC is relatively low. Hence, we'd like to always load CSS async for client side rendered application, this will result in critters running on a document which contains link tags marked as "lazy/async".

If you are interested further about what we'd like to do you can have a look at: angular/angular-cli#18730

For illustration purposes here's the step by step build/rendering pipeline:

(c) |- Generate browser bundle and HTML document
(o,c) |- Generate App-shell the generated browser bundle and HTML
(o,c) |- Prerender using the generated browser bundle, app-shell and HTML
(o,c) |- Start node server for SSR using the generated browser bundle, app-shell and HTML

Legend
c: critters is run in this stage
o: optional step

I know that these might not be the atypical use-cases that this tools was designed for.

Please let me know what you think.

from critters.

naveedahmed1 avatar naveedahmed1 commented on June 9, 2024

Any update on this?

from critters.

developit avatar developit commented on June 9, 2024

This seems like it might be a bit tricky to detect when a given <noscript> is one Critters previously injected, versus something a developer has added. Also - @alan-agius4 I guess the standard critters inlining ends up avoiding duplication because we deduplicate selectors? Or are you setting the reduceInlineStyles:false option?

from critters.

alan-agius4 avatar alan-agius4 commented on June 9, 2024

@developit, we are using reduceInlineStyles:false.

The main reason for this is, so that between the transition from the SSR'd view to CSR view. Angular will remove/or re-use components <styles> generated on the server. However, when using reduceInlineStyles this is not possible because all styles are merged into a single style tag and causes metadata that is needed for styles to be be re-used to be lost, since this data is stored as attributed on style tags.

Overall, I am fine with closing this request. We did find a workaround to get around this.

from critters.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.