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.

[template-renderer] Make it possible to not automatically render used async scripts

See original GitHub issue

What problem does this feature solve?

In oder to make https://github.com/maoberlehner/vue-lazy-hydration more useful it would be great if we could prevent the template renderer from automatically injecting async scripts. The way vue-lazy-hydration works is, that it behaves differently on the server than it does on the client. On the server the script (of an async component) is loaded immediately so the template renderer correctly detects that it is used. But on the client the script might not be needed at all but because the template renderer has already injected it it is immediately loaded on page load.

There is currently kind of a backlash against loading huge amounts of JavaScript. vue-lazy-hydration can help with removing a lot of unnecessary JavaScript on server side rendered, mostly static sites like blogs and documentation. But currently it can’t completely prevent loading all of the unnecessary JavaScript because of the way how template renderer works.

Here is the relevant line in the code: https://github.com/vuejs/vue/blob/dev/src/server/template-renderer/index.js#L226

What does the proposed API look like?

I propose to make this configurable:

const renderer = createBundleRenderer(serverBundle, {
  template,
  renderUsedAsyncScripts: false,
});

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:68
  • Comments:26

github_iconTop GitHub Comments

17reactions
simllllcommented, Dec 30, 2019

this is the related PR https://github.com/vuejs/vue/pull/10794 anything we can do to get this into the core?

13reactions
simplenotezycommented, Mar 6, 2020

That would be neat, Vue & Nuxt applications would see a huge performance boost, especially on LightHouse scores.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NetSuite Applications Suite - render.TemplateRenderer
Implement Asynchronous and Synchronous Methods ... Checking for Item Filters in an Order Form Used by NetSuite Connector ... render.TemplateRenderer.
Read more >
Eliminate Render-Blocking JavaScript with Async and Defer
Async and defer are two HTML5 attributes that allow delaying execution of scripts, eliminating blocking JavaScript. A must for performance!
Read more >
Text Templating | Documentation Center | ABP.IO
Text templating is used to dynamically render contents based on a template ... templateRenderer; } public async Task RunAsync() { var result ...
Read more >
JavaScript Data Grid: Cell Renderer - AG Grid
Everyone can use AG Grid Community for free. It's MIT licensed and Open Source. No restrictions. No strings attached. Enterprise. Do you want...
Read more >
Vue <script setup> Top level await causing template not to ...
Top-level await must be used in combination with Suspense (which is experimental). You should be able to just do it in onBeforeMount ....
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