aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2024-05-30 09:38:39 +0200
committerGitHub <[email protected]>2024-05-30 07:38:39 +0000
commit9daff544930fb34c75dec6d03087e21be7446d90 (patch)
treea1ed61625b4b154c634cc51f2221f446a136947b /docs
parent29df38468fc90efaaf749a5c39a1b2c1f2e6bf46 (diff)
downloadfaker-9daff544930fb34c75dec6d03087e21be7446d90.tar.xz
faker-9daff544930fb34c75dec6d03087e21be7446d90.zip
docs: browser console usage guide (#2919)
Diffstat (limited to 'docs')
-rw-r--r--docs/guide/usage.md24
1 files changed, 21 insertions, 3 deletions
diff --git a/docs/guide/usage.md b/docs/guide/usage.md
index f19721c2..c9197479 100644
--- a/docs/guide/usage.md
+++ b/docs/guide/usage.md
@@ -26,10 +26,22 @@ const randomEmail = faker.internet.email(); // [email protected]
:::
-For more information about changing and customizing the locales, please refer to our [Localization Guide](localization).
+For more information on selecting and customizing a locale, please refer to our [Localization Guide](localization).
## Browser
+If you want to try it yourself, you can open your browser console via `Ctrl + Shift + J` / `F12`.
+
+```js
+const { faker } = await import('https://esm.sh/@faker-js/faker');
+
+const randomName = faker.person.fullName(); // Amber Keebler
+const randomEmail = faker.internet.email(); // [email protected]
+```
+
+Some websites may have protections against downloading external code, dev servers usually work fine.
+As an alternative, you can create a simple html file and open it with your browser:
+
```html
<script type="module">
import { faker } from 'https://esm.sh/@faker-js/faker';
@@ -39,11 +51,17 @@ For more information about changing and customizing the locales, please refer to
const randomEmail = faker.internet.email();
+
+ document.getElementById('name').value = randomName;
+ document.getElementById('email').value = randomEmail;
</script>
+
+<input id="name" />
+<input id="email" />
```
::: info Note
-Using the browser is great for experimenting 👍. However, due to all of the strings Faker uses to generate fake data, **Faker is a large package**. It's `> 5 MiB` minified. **Please avoid deploying the full Faker in your web app.**
+Using the browser is great for experimenting 👍. However, due to all of the strings Faker uses to generate fake data, **Faker is a large package**. It's `> 5 MiB` minified. **Please avoid deploying the full Faker package in your web app.**
:::
## CDN/Deno
@@ -56,7 +74,7 @@ const randomEmail = faker.internet.email(); // [email protected]
```
::: info Note
-It is highly recommended to use version tags when importing libraries in Deno, e.g: `import { faker } from "https://esm.sh/@faker-js/[email protected]"`.
+It is highly recommended to use version tags when importing libraries in Deno, e.g: `import { faker } from "https://esm.sh/@faker-js/[email protected]"`.
:::
### Alternative CDN links