Skip to content

Commit 58b458d

Browse files
docs: translate script.md to Русский
1 parent 2958f53 commit 58b458d

1 file changed

Lines changed: 41 additions & 39 deletions

File tree

  • src/content/reference/react-dom/components

‎src/content/reference/react-dom/components/script.md‎

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
```html
12
---
23
script: "<script>"
34
---
45
56
<Intro>
67
7-
The [built-in browser `<script>` component](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) lets you add a script to your document.
8+
Встроенный в браузер компонент `<script>` позволяет добавить скрипт в ваш документ.
89
910
```js
1011
<script> alert("hi!") </script>
@@ -16,71 +17,71 @@ The [built-in browser `<script>` component](https://developer.mozilla.org/en-US/
1617
1718
---
1819
19-
## Reference {/*reference*/}
20+
## Справочник {/*reference*/}
2021
2122
### `<script>` {/*script*/}
2223
23-
To add inline or external scripts to your document, render the [built-in browser `<script>` component](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script). You can render `<script>` from any component and React will [in certain cases](#special-rendering-behavior) place the corresponding DOM element in the document head and de-duplicate identical scripts.
24+
Чтобы добавить встроенные или внешние скрипты в ваш документ, используйте встроенный в браузер компонент `<script>`. Вы можете рендерить `<script>` из любого компонента, и React [в некоторых случаях](#special-rendering-behavior) поместит соответствующий DOM-элемент в `<head>` документа и будет дедуплицировать идентичные скрипты.
2425
2526
```js
2627
<script> alert("hi!") </script>
2728
<script src="script.js" />
2829
```
2930
30-
[See more examples below.](#usage)
31+
[См. больше примеров ниже.](#usage)
3132
32-
#### Props {/*props*/}
33+
#### Пропсы {/*props*/}
3334
34-
`<script>` supports all [common element props.](/reference/react-dom/components/common#props)
35+
`<script>` поддерживает все [общие пропсы элементов.](/reference/react-dom/components/common#props)
3536
36-
It should have *either* `children` or a `src` prop.
37+
Он должен иметь *либо* `children`, *либо* пропс `src`.
3738
38-
* `children`: a string. The source code of an inline script.
39-
* `src`: a string. The URL of an external script.
39+
* `children`: строка. Исходный код встроенного скрипта.
40+
* `src`: строка. URL внешнего скрипта.
4041
41-
Other supported props:
42+
Другие поддерживаемые пропсы:
4243
43-
* `async`: a boolean. Allows the browser to defer execution of the script until the rest of the document has been processed — the preferred behavior for performance.
44-
* `crossOrigin`: a string. The [CORS policy](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) to use. Its possible values are `anonymous` and `use-credentials`.
45-
* `fetchPriority`: a string. Lets the browser rank scripts in priority when fetching multiple scripts at the same time. Can be `"high"`, `"low"`, or `"auto"` (the default).
46-
* `integrity`: a string. A cryptographic hash of the script, to [verify its authenticity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity).
47-
* `noModule`: a boolean. Disables the script in browsers that support ES modules — allowing for a fallback script for browsers that do not.
48-
* `nonce`: a string. A cryptographic [nonce to allow the resource](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) when using a strict Content Security Policy.
49-
* `referrer`: a string. Says [what Referer header to send](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#referrerpolicy) when fetching the script and any resources that the script fetches in turn.
50-
* `type`: a string. Says whether the script is a [classic script, ES module, or import map](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type).
44+
* `async`: булево значение. Позволяет браузеру отложить выполнение скрипта до тех пор, пока остальная часть документа не будет обработана — предпочтительное поведение для производительности.
45+
* `crossOrigin`: строка. Используемая [политика CORS](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin). Возможные значения: `anonymous` и `use-credentials`.
46+
* `fetchPriority`: строка. Позволяет браузеру ранжировать скрипты по приоритету при одновременной загрузке нескольких скриптов. Может быть `"high"`, `"low"` или `"auto"` (по умолчанию).
47+
* `integrity`: строка. Криптографический хеш скрипта для [проверки его подлинности](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity).
48+
* `noModule`: булево значение. Отключает скрипт в браузерах, поддерживающих ES-модули — позволяя использовать запасной скрипт для браузеров, которые их не поддерживают.
49+
* `nonce`: строка. Криптографический [nonce для разрешения ресурса](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) при использовании строгой политики безопасности контента (Content Security Policy).
50+
* `referrer`: строка. Указывает, какой [заголовок Referer отправлять](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#referrerpolicy) при загрузке скрипта и любых ресурсов, которые скрипт загружает в свою очередь.
51+
* `type`: строка. Указывает, является ли скрипт [классическим скриптом, ES-модулем или картой импорта](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type).
5152
52-
Props that disable React's [special treatment of scripts](#special-rendering-behavior):
53+
Пропсы, отключающие [специальное поведение React для скриптов](#special-rendering-behavior):
5354
54-
* `onError`: a function. Called when the script fails to load.
55-
* `onLoad`: a function. Called when the script finishes being loaded.
55+
* `onError`: функция. Вызывается, когда скрипт не удаётся загрузить.
56+
* `onLoad`: функция. Вызывается, когда скрипт успешно загружен.
5657
57-
Props that are **not recommended** for use with React:
58+
Пропсы, которые **не рекомендуется** использовать с React:
5859
59-
* `blocking`: a string. If set to `"render"`, instructs the browser not to render the page until the scriptsheet is loaded. React provides more fine-grained control using Suspense.
60-
* `defer`: a string. Prevents the browser from executing the script until the document is done loading. Not compatible with streaming server-rendered components. Use the `async` prop instead.
60+
* `blocking`: строка. Если установлено значение `"render"`, браузеру предписывается не отображать страницу до загрузки скрипта. React предоставляет более детальный контроль с помощью Suspense.
61+
* `defer`: строка. Предотвращает выполнение скрипта браузером до завершения загрузки документа. Несовместимо со стриминговыми серверно-отрендеренными компонентами. Вместо этого используйте пропс `async`.
6162
62-
#### Special rendering behavior {/*special-rendering-behavior*/}
63+
#### Специальное поведение рендеринга {/*special-rendering-behavior*/}
6364
64-
React can move `<script>` components to the document's `<head>` and de-duplicate identical scripts.
65+
React может перемещать компоненты `<script>` в `<head>` документа и дедуплицировать идентичные скрипты.
6566
66-
To opt into this behavior, provide the `src` and `async={true}` props. React will de-duplicate scripts if they have the same `src`. The `async` prop must be true to allow scripts to be safely moved.
67+
Чтобы использовать это поведение, предоставьте пропсы `src` и `async={true}`. React будет дедуплицировать скрипты, если у них одинаковый `src`. Пропс `async` должен быть `true`, чтобы скрипты можно было безопасно перемещать.
6768
68-
This special treatment comes with two caveats:
69+
Это специальное поведение имеет два нюанса:
6970
70-
* React will ignore changes to props after the script has been rendered. (React will issue a warning in development if this happens.)
71-
* React may leave the script in the DOM even after the component that rendered it has been unmounted. (This has no effect as scripts just execute once when they are inserted into the DOM.)
71+
* React будет игнорировать изменения пропсов после рендеринга скрипта. (В режиме разработки React выдаст предупреждение, если это произойдет.)
72+
* React может оставить скрипт в DOM даже после того, как компонент, который его рендерил, будет размонтирован. (Это не имеет значения, так как скрипты выполняются только один раз при вставке в DOM.)
7273
7374
---
7475
75-
## Usage {/*usage*/}
76+
## Использование {/*usage*/}
7677
77-
### Rendering an external script {/*rendering-an-external-script*/}
78+
### Рендеринг внешнего скрипта {/*rendering-an-external-script*/}
7879
79-
If a component depends on certain scripts in order to be displayed correctly, you can render a `<script>` within the component.
80-
However, the component might be committed before the script has finished loading.
81-
You can start depending on the script content once the `load` event is fired e.g. by using the `onLoad` prop.
80+
Если компонент зависит от определённых скриптов для корректного отображения, вы можете рендерить `<script>` внутри компонента.
81+
Однако компонент может быть зафиксирован до того, как скрипт будет полностью загружен.
82+
Вы можете начать использовать содержимое скрипта после срабатывания события `load`, например, с помощью пропса `onLoad`.
8283
83-
React will de-duplicate scripts that have the same `src`, inserting only one of them into the DOM even if multiple components render it.
84+
React будет дедуплицировать скрипты с одинаковым `src`, вставляя только один из них в DOM, даже если несколько компонентов рендерят его.
8485
8586
<SandpackWithHTMLOutput>
8687
@@ -108,12 +109,12 @@ export default function Page() {
108109
</SandpackWithHTMLOutput>
109110
110111
<Note>
111-
When you want to use a script, it can be beneficial to call the [preinit](/reference/react-dom/preinit) function. Calling this function may allow the browser to start fetching the script earlier than if you just render a `<script>` component, for example by sending an [HTTP Early Hints response](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103).
112+
Когда вы хотите использовать скрипт, может быть полезно вызвать функцию [preinit](/reference/react-dom/preinit). Вызов этой функции может позволить браузеру начать загрузку скрипта раньше, чем если бы вы просто рендерили компонент `<script>`, например, отправив [HTTP Early Hints ответ](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103).
112113
</Note>
113114
114-
### Rendering an inline script {/*rendering-an-inline-script*/}
115+
### Рендеринг встроенного скрипта {/*rendering-an-inline-script*/}
115116
116-
To include an inline script, render the `<script>` component with the script source code as its children. Inline scripts are not de-duplicated or moved to the document `<head>`.
117+
Чтобы включить встроенный скрипт, рендерите компонент `<script>` с исходным кодом скрипта в качестве его дочерних элементов. Встроенные скрипты не дедуплицируются и не перемещаются в `<head>` документа.
117118
118119
<SandpackWithHTMLOutput>
119120
@@ -140,3 +141,4 @@ export default function Page() {
140141
```
141142
142143
</SandpackWithHTMLOutput>
144+
```

0 commit comments

Comments
 (0)