Skip to content

Commit 34c6136

Browse files
docs: translate <script> page (#721)
Co-authored-by: Resi Respati <resir014@gmail.com>
1 parent 3c39a1b commit 34c6136

File tree

1 file changed

+39
-39
lines changed
  • src/content/reference/react-dom/components

1 file changed

+39
-39
lines changed

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

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ canary: true
55

66
<Canary>
77

8-
React's extensions to `<script>` are currently only available in React's canary and experimental channels. In stable releases of React `<script>` works only as a [built-in browser HTML component](https://react.dev/reference/react-dom/components#all-html-components). Learn more about [React's release channels here](/community/versioning-policy#all-release-channels).
8+
Ekstensi React untuk `<script>` saat ini hanya tersedia di kanal *canary* dan eksperimental React. Dalam rilis stabil React, `<script>` berfungsi sebagai [komponen HTML browser bawaan](https://react.dev/reference/react-dom/components#all-html-components). Pelajari lebih lanjut tentang [kanal rilis React di sini.](/community/versioning-policy#all-release-channels).
99

1010
</Canary>
1111

1212
<Intro>
1313

14-
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.
14+
[Komponen `<script>` bawaan browser](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) memungkinkan Anda menambahkan *script* di dokumen anda.
1515

1616
```js
1717
<script> alert("hi!") </script>
@@ -23,71 +23,71 @@ The [built-in browser `<script>` component](https://developer.mozilla.org/en-US/
2323

2424
---
2525

26-
## Reference {/*reference*/}
26+
## Referensi {/*reference*/}
2727

2828
### `<script>` {/*script*/}
2929

30-
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.
30+
Untuk menambahkan *script* eksternal atau sisipan pada document, render [komponen bawaan `<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script). Anda bisa merender `<script>` dari komponen apapun dan React [dalam kasus tertentu](#special-rendering-behavior) akan menempatkan elemen DOM yang sesuai isi di kepala dokumen dan menghapus *script* duplikat yang identik.
3131

3232
```js
3333
<script> alert("hi!") </script>
3434
<script src="script.js" />
3535
```
3636

37-
[See more examples below.](#usage)
37+
[Lihat contoh lainnya di bawah.](#usage)
3838

3939
#### Props {/*props*/}
4040

41-
`<script>` supports all [common element props.](/reference/react-dom/components/common#props)
41+
`<script>` mendukung segala [props elemen umum.](/reference/react-dom/components/common#props)
4242

43-
It should have *either* `children` or a `src` prop.
43+
Seharusnya memiliki *salah satu* props `children` atau `src`.
4444

45-
* `children`: a string. The source code of an inline script.
46-
* `src`: a string. The URL of an external script.
45+
* `children`: sebuah string. Sumber kode *script* sisipan.
46+
* `src`: sebuah string. URL dari eksternal *script*.
4747

48-
Other supported props:
48+
Props lain yang didukung:
4949

50-
* `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.
51-
* `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`.
52-
* `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).
53-
* `integrity`: a string. A cryptographic hash of the script, to [verify its authenticity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity).
54-
* `noModule`: a boolean. Disables the script in browsers that support ES modules — allowing for a fallback script for browsers that do not.
55-
* `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.
56-
* `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.
57-
* `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).
50+
* `async`: sebuah boolean. Mengizinkan browser menunda eksekusi *script* hingga seluruh dokumen telah diproses — perilaku yang lebih baik untuk performa.
51+
* `crossOrigin`: sebuah string. [Aturan CORS](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) yang digunakan. Nilai yang memungkinkan adalah `anonymous` dan `use-credentials`.
52+
* `fetchPriority`: sebuah string. Memungkinkan browser memberikan peringkat *script* pada prioritas saat mengambil beberapa *script* secara bersamaan. Dapat berupa `"high"`, `"low"`, atau `"auto"` (nilai bawaan).
53+
* `integrity`: sebuah string. Hash kriptografi dari *script*, untuk [memverifikasi keaslian](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity).
54+
* `noModule`: sebuah boolean. Menonaktifkan *script* di browser yang mendukung modul ES — memungkinkan *script* cadangan untuk browser yang tidak mendukungnya.
55+
* `nonce`: sebuah string. Kriptografi [nonce untuk mengizinkan sumber daya](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) saat menggunakan sebuah aturan yang ketat mengenai Content Security.
56+
* `referrer`: sebuah string. Mengatakan [apa kepala Referer yang mau dikirim](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#referrerpolicy) saat mengambil *script* dan sumber daya apa pun yang diambil oleh *script* secara bergantian.
57+
* `type`: sebuah string. Apakah script ini merupakan[*script* klasik, modul ES, or *import map*](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type).
5858

59-
Props that disable React's [special treatment of scripts](#special-rendering-behavior):
59+
Props yang menonaktifkan [perlakuan khusus pada *script*](#special-rendering-behavior) React:
6060

61-
* `onError`: a function. Called when the script fails to load.
62-
* `onLoad`: a function. Called when the script finishes being loaded.
61+
* `onError`: sebuah fungsi. Dipanggil saat *script* gagal dimuat.
62+
* `onLoad`: sebuah fungsi. Dipanggil saat *script* telah berhasil dimuat.
6363

64-
Props that are **not recommended** for use with React:
64+
Props yang **tidak direkomendasikan** untuk digunakan di React:
6565

66-
* `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.
67-
* `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.
66+
* `blocking`: sebuah string. Jika dipasang ke `"render"`, memerintahkan browser untuk tidak merender halaman sampai lembar *script* dimuat. React memberikan kontrol yang lebih halus menggunakan Suspense.
67+
* `defer`: sebuah string. Mencegah browser menjalankan *script* hingga dokumen selesai dimuat. Tidak kompatibel dengan komponen yang dirender oleh *server streaming*. Gunakan prop `async` sebagai gantinya.
6868

69-
#### Special rendering behavior {/*special-rendering-behavior*/}
69+
#### Perilaku rendering khusus {/*special-rendering-behavior*/}
7070

71-
React can move `<script>` components to the document's `<head>` and de-duplicate identical scripts.
71+
React dapat memindahkan komponen `<script>` ke `<head>` dokumen dan menghapus *script* duplikat yang identik.
7272

73-
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.
73+
Untuk mengikuti perilaku ini, berikan props `src` dan `async={true}`. React akan menghapus *script* duplikat jika skrip tersebut memiliki `src` yang sama. Prop `async` harus memiliki nilai *true* agar *script* dapat dipindahkan dengan aman.
7474

75-
This special treatment comes with two caveats:
75+
Perlakuan khusus ini disertai dengan dua peringatan:
7676

77-
* React will ignore changes to props after the script has been rendered. (React will issue a warning in development if this happens.)
78-
* 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.)
77+
* React akan mengabaikan perubahan pada props setelah *script* dirender. (React akan mengeluarkan peringatan dalam pengembangan jika ini terjadi.)
78+
* React mungkin meninggalkan *script* di DOM bahkan setelah komponen yang merendernya telah dilepas. (Ini tidak berpengaruh karena *script* hanya dijalankan satu kali ketika dimasukkan ke dalam DOM.)
7979

8080
---
8181

82-
## Usage {/*usage*/}
82+
## Penggunaan {/*usage*/}
8383

84-
### Rendering an external script {/*rendering-an-external-script*/}
84+
### Merender *script* eksternal {/*rendering-an-external-script*/}
8585

86-
If a component depends on certain scripts in order to be displayed correctly, you can render a `<script>` within the component.
87-
However, the component might be committed before the script has finished loading.
88-
You can start depending on the script content once the `load` event is fired e.g. by using the `onLoad` prop.
86+
Jika suatu komponen bergantung pada *script* tertentu agar dapat ditampilkan dengan benar, Anda dapat merender `<script>` di dalam komponen tersebut.
87+
Namun, komponen mungkin di-*commit* sebelum *script* selesai dimuat.
88+
Anda dapat mulai bergantung pada konten *script* setelah acara `load` diaktifkan, mis. dengan menggunakan prop `onLoad`.
8989

90-
React will de-duplicate scripts that have the same `src`, inserting only one of them into the DOM even if multiple components render it.
90+
React akan menghapus *script* duplikat yang memiliki `src` yang sama, hanya memasukkan salah satu *script* tersebut ke dalam DOM meskipun beberapa komponen merendernya.
9191

9292
<SandpackWithHTMLOutput>
9393

@@ -115,12 +115,12 @@ export default function Page() {
115115
</SandpackWithHTMLOutput>
116116

117117
<Note>
118-
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).
118+
Saat Anda ingin menggunakan *script*, akan bermanfaat jika memanggil fungsi [preinit](/reference/react-dom/preinit). Memanggil fungsi ini memungkinkan browser untuk mulai mengambil *script* lebih awal dibandingkan jika Anda hanya merender komponen `<script>`, misalnya dengan mengirimkan [respons Early Hints HTTP](https://developer.mozilla.org/en-US/dokumen/Web/HTTP/Status/103).
119119
</Note>
120120

121-
### Rendering an inline script {/*rendering-an-inline-script*/}
121+
### Merender *script* sisipan {/*rendering-an-inline-script*/}
122122

123-
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>`.
123+
Untuk menyertakan *script sisipan*, render komponen `<script>` dengan kode sumber *script* sebagai turunannya. *Script* sebaris tidak dihapus duplikatnya atau dipindahkan ke dokumen `<head>`.
124124

125125
<SandpackWithHTMLOutput>
126126

0 commit comments

Comments
 (0)