Skip to content

Use rendered rather than emitted CSS in AMP mode #808

Closed
@Rich-Harris

Description

@Rich-Harris

Is your feature request related to a problem? Please describe.
AMP pages have a strict (and somewhat arbitrary) limit on the amount of CSS a page can include. They also provide a guarantee that doesn't exist in non-AMP mode, namely that if condition is false at SSR time...

<script>
  import Foo from '$lib/components/Foo.svelte';

  export let condition;
</script>

{#if condition}
  <Foo/>
{/if}

...we can safely omit the styles emitted by Foo.svelte.

It would be nice if we could take advantage of that and only include styles for components that were rendered, to increase the likelihood of staying beneath the 75kb ceiling.

Describe the solution you'd like

  • Configure the Svelte plugin to not emit CSS in AMP mode
  • Use rendered.css instead of inspecting the module graph

How important is this feature to you?
It depends on the outcome of the research we plan to conduct on how much traffic our app would lose if we told AMP to bugger off once and for all.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions