Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Sep 7, 2023. It is now read-only.
This repository was archived by the owner on Sep 7, 2023. It is now read-only.

/translations.js slows down Searx. #2064

@dalf

Description

@dalf

This commit 4ca0d8c adds a new URL to serve a non static javascript file.

The script is loaded in the <head> section of the HTML page: https://github.com/asciimoo/searx/blob/4ca0d8cb0fd6c0e6b1301a6e8577aea6d928e9dc/searx/templates/oscar/base.html#L13

It takes usually at least 100ms to download (5% of 2 seconds), sometimes more, and since it is in the <head> section, the browser waits until the URL is downloaded and the content parsed. The file is reloaded each time since the user can change the locale.

You can see that in the devtools of a browser, or using curl:

curl     --write-out "%{http_code},%{time_total},%{time_connect},%{time_appconnect},%{time_starttransfer}\n"     --silent     --output /dev/null     "https://searx.be/translations.js"

It slows down Searx page load.

solution 1: remove translations.js

This solution is good for now because there is only one string to translate (in the oscar theme).
If there are more than one translation, a JSON structure can be serialized:

<script src="searx.min.js" ... data-i18n="{ 'could_not_load': 'could not load data!' }" />

Side note: the simple theme already does something similar (see no_item_found):

solution 2: translations.<:locale>.js

Instead of one dynamic file, there is one per locale. The HTTP headers make sure the browser keeps the files in the cache.
This solution leak the user locale in the reverse proxy logs.

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