Skip to content

Performance

Performance-related visible settings on the browser side are given via the data-luis attribute. This page covers only the runtime values you give directly.

<link rel="stylesheet" href="./styles.luis" data-luis="lazy">

data-luis valueEffectWhen to use
lazyActivates observed rules later based on the viewportWhen you want to lighten the initial load on long pages
workerForces compilation onto the worker pathWhen you want to free up the main thread on large .luis sources
!workerKeeps compilation on the main threadWhen you don't want a worker or want to pin the behavior

Multiple values can be given together:

<link rel="stylesheet" href="./styles.luis" data-luis="lazy,worker">

lazy is used when you want to produce less CSS on the initial load, especially for observed rules.

<link rel="stylesheet" href="./cards.luis" data-luis="lazy">

Short effect:

  • viewport content comes first
  • observed areas further down activate later
  • reduces initial load on long document and list pages

lazy makes a difference especially for rules written with ? and ?!.

SituationBehavior
If selector is in viewport on first compilationRule is generated
If selector is outside viewport on first compilationWaits; generated when it enters the viewport
If element is later added to the DOMGenerated
SituationBehavior
If selector is in viewport on first compilationRule is generated
If selector is outside viewport on first compilationWaits; generated when it enters the viewport
If a new element matching the same selector is later added to the DOMNot generated
??!
If starting in viewportGeneratedGenerated
If starting outside viewportWaits on entry, generated when visibleWaits on entry, generated when visible
If later added to DOMGeneratedNot generated

worker forces .luis compilation onto the worker side.

<link rel="stylesheet" href="./dashboard.luis" data-luis="worker">

Short effect:

  • load on the main thread is reduced for large sources
  • fewer freezes during scroll, click, and input
  • compilation behavior becomes safer for heavier pages

worker does not change observed semantics. That is, when ? and ?! rules activate remains the same; what changes is which side the compilation work runs on.

Rule typeWithout workerWith worker
?Activates when DOM matchesSame
?!Activates for first appropriate matchesSame
lazy + ?May be delayed based on viewportSame
lazy + ?!Opens for first visible matches, not for newly added onesSame

So the worker choice answers this question:

  • do you want to move the compile load off the main thread?

But it does not change this question:

  • do you want to set up observed behavior with ? or ?!?
<link rel="stylesheet" href="./feed.luis" data-luis="worker">

In this usage:

  • the compilation of the large .luis file is moved to the worker side
  • but .card? still remains as dynamic observed
  • .hero?! still remains as initial observed

!worker disables the worker path and keeps compilation on the main thread.

<link rel="stylesheet" href="./small-widget.luis" data-luis="!worker">

You generally use this when:

  • the source is small
  • you don't want to use a worker
  • you want to explicitly pin the behavior

Most common combination:

<link rel="stylesheet" href="./feed.luis" data-luis="lazy,worker">

This combination means:

  • observed activation becomes later and more selective
  • compilation work is moved to the worker side
SituationResult
.item? is outside viewportLazy waits; activates when visible
.item? is later added to DOMActivates dynamically
.item?! is outside viewportLazy waits; activates when visible
.item?! is later added to DOMDoes not activate again

In this combination:

  • lazy affects when the observed rule opens
  • worker affects which side the compilation runs on

So one controls timing, the other controls the execution path.


If data-luis is not given at all, the runtime uses default behavior:

<link rel="stylesheet" href="./styles.luis">

In this case:

  • lazy is not on
  • worker is not forced
  • it is also not disabled with !worker