searxng/client/simple
Markus Heiser d2b3c92e81 [fix] move initial "JS is enabled?" (no-js) to client side
To avoid an `unsafe-inline` in the CSP header, the JS code must be moved to the
client side [1].

The `<script>` tag at the end of the HTML originates from the old implementation
of the JS client. Since PR-5073 [2] was merged, the `type` is now `module`, and
the tag must be moved to the beginning of the HTML.

> We need to inline this "JS is enabled?" thing to prevent layout shifts and
> temporary "no JS enabled" visuals as ESM scripts loads and evals everything
> deferred from initial DOM render [3]

That's true in theory, but in practice, this effect is unnoticeable because it's
masked by another effect (which we can't avoid): If we load the page with a
severely throttled connection, the HTML (result list) takes a long time to
load. Then the CSS is loaded, which also takes longer. Until the CSS has loaded,
there's no layout. A layout shift is therefore largely determined by the loading
of the HTML and CSS itself.

The running times of the ESM script can be neglected compared to the loading
times of HTML & CSS.

[1] https://github.com/searxng/searxng-docker/pull/424#issuecomment-3199494256
[2] https://github.com/searxng/searxng/pull/5073
[3] https://github.com/searxng/searxng-docker/pull/424#issuecomment-3199622504
2025-08-21 09:07:08 +02:00
..
generated [license] client/simple: SPDX-License-Identifier: AGPL-3.0-or-later 2025-08-18 16:38:32 +02:00
src [fix] move initial "JS is enabled?" (no-js) to client side 2025-08-21 09:07:08 +02:00
tools [license] client/simple: SPDX-License-Identifier: AGPL-3.0-or-later 2025-08-18 16:38:32 +02:00
.gitignore [mod] theme/simple: improve fmt/lint tech 2025-07-03 17:35:05 +02:00
.stylelintrc.json [mod] theme/simple: improve fmt/lint tech 2025-07-03 17:35:05 +02:00
biome.json [upd] web-client (simple): Bump the minor group across 1 directory with 6 updates (#5128) 2025-08-18 23:17:50 +02:00
package-lock.json [upd] web-client (simple): Bump the minor group across 1 directory with 6 updates (#5128) 2025-08-18 23:17:50 +02:00
package.json [upd] web-client (simple): Bump the minor group across 1 directory with 6 updates (#5128) 2025-08-18 23:17:50 +02:00
README.rst [web-client] simple theme: build & development env based on vite. 2025-02-28 12:27:41 +01:00
theme_icons.ts [license] client/simple: SPDX-License-Identifier: AGPL-3.0-or-later 2025-08-18 16:38:32 +02:00
tsconfig.json [mod] theme/simple: migrate codebase to TypeScript 2025-08-18 16:38:32 +02:00
vite.config.ts [license] client/simple: SPDX-License-Identifier: AGPL-3.0-or-later 2025-08-18 16:38:32 +02:00

=====================
MEMO vite development
=====================

Local install::

  # in folder ./client/simple/
  $ npm install

Start development server::

  $ ./manage vite.simple.dev

  # in folder ./client/simple/
  $ npm exec -- vite

Fix source code::

  # in folder ./client/simple/
  $ npm run fix

Fix & Build::

  $ ./manage vite.simple.build