Giter Club home page Giter Club logo

Comments (7)

davidtheclark avatar davidtheclark commented on July 23, 2024

Awesome write-up, @kepta! Just two follow-up questions for you:

  • Do you think it's necessary to pass renderJsBundles and renderCssLinks functions into the HTML-rendering function, or do you think we'd serve our use cases by automatically injecting those things (at the end of </body> and </head>, respectively)?
  • What do you think about the HTML-rendering function returning either a string or a Promise that resolves with a string?

from underreact.

davidtheclark avatar davidtheclark commented on July 23, 2024

@kepta What do you think our polyfill strategy should be?

from underreact.

kepta avatar kepta commented on July 23, 2024

Do you think it's necessary to pass renderJsBundles and renderCssLinks functions into the HTML-rendering function, or do you think we'd serve our use cases by automatically injecting those things (at the end of and , respectively)?

I don't see any benefit in auto injecting them behind the scenes. On a plus side, pro-users would be happy to take command over the placement.

What do you think about the HTML-rendering function returning either a string or a Promise that resolves with a string?

Oops, I forgot to mention that, thanks for reminding. (updated the ticket)

from underreact.

kepta avatar kepta commented on July 23, 2024

@kepta What do you think our polyfill strategy should be?

@davidtheclark getting inspired by webpack, I propose that we use a default polyfill file and provide a polyfillInject() function in our async HTML-rednering function:

{
  htmlSource: ({ renderJsBundles, polyfillInject , renderCssLinks }) => `
      <html>
      <head>
       <title>Words that rhyme with fish</title>
         ${polyfillInject()}
        <link href="https://api.mapbox.com/mapbox-assembly/v0.21.2/assembly.min.css" rel="stylesheet">
        ${renderCssLinks()}
      </head>
      <body>
        <div id="app">
          <!-- React app will be rendered into this div -->
        </div>
        ${renderJsBundles()}
      </body>
      </html>
    `;
}

This polyfillInject function would do something similar to what webpack proposes, that is

  var modernBrowser = (
    'fetch' in window &&
    'assign' in Object
  );

  if ( !modernBrowser ) {
    var scriptElement = document.createElement('script');

    scriptElement.async = false;
    scriptElement.src = '/polyfills.bundle.js';
    document.head.appendChild(scriptElement);
  }

Thoughts?

from underreact.

davidtheclark avatar davidtheclark commented on July 23, 2024

I don't see any benefit in auto injecting them behind the scenes.

The benefit would be that if it's always done in exactly the same way, you don't have to repeat the boilerplate every time. I wasn't sure about those functions any more because I couldn't think of any use cases for doing anything different with them: in every case, you should put the links at the end of </head> and the scripts at the end of </body>. Can you think of use cases for using those functions in any other way?

Interesting idea for polyfilling. So we'll need to decide which polyfills to include and what modernBrowser test covers them all sufficiently.

from underreact.

kepta avatar kepta commented on July 23, 2024

Can you think of use cases for using those functions in any other way?

I think the functions provide a transparent way of templating the html. But if we are never gonna change their order we can possibly do them behind the scene.

So we'll need to decide which polyfills to include and what modernBrowser test covers them all sufficiently.

Ya we will need a default list of polyfills, I wonder if the browserslist can help us with that?

from underreact.

kepta avatar kepta commented on July 23, 2024

Underreact was released 🎉 !

from underreact.

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.