Skip to content

Commit

Permalink
docs: apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT committed May 28, 2024
1 parent d3568be commit c9ee4d3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
29 changes: 18 additions & 11 deletions docs/guide/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ For more information on selecting and customizing a locale, please refer to our

## 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(); // Norma13@hotmail.com
```

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';
Expand All @@ -39,24 +51,19 @@ For more information on selecting and customizing a locale, please refer to our
// Rusty@arne.info
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.**
:::

## Browser Console

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(); // Norma13@hotmail.com
```

## CDN/Deno

```js
Expand Down
15 changes: 15 additions & 0 deletions test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script type="module">
import { faker } from 'https://esm.sh/@faker-js/faker';

// Caitlyn Kerluke
const randomName = faker.person.fullName();

// Rusty@arne.info
const randomEmail = faker.internet.email();

document.getElementById('name').value = randomName;
document.getElementById('email').value = randomEmail;
</script>

<input id="name" />
<input id="email" />

0 comments on commit c9ee4d3

Please sign in to comment.