From 649bbb44efd7ce2d131ae1f72e5c769a7540a6d5 Mon Sep 17 00:00:00 2001 From: redhoodsu Date: Thu, 11 Jul 2024 19:47:54 +0800 Subject: [PATCH] docs: modern js usage example --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8da5147e7..5d28fecc5 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ javascript:(function () { var script = document.createElement('script'); script. You can get it on npm. ```bash -npm install eruda --save +npm install eruda --save-dev ``` Add this script to your page. @@ -86,6 +86,14 @@ The JavaScript file size is quite huge(about 100kb gzipped) and therefore not su })(); ``` +If you are using modern JavaScript tooling, you can dynamically import it. + +```javascript +if (import.meta.env.MODE === 'development') { + import('eruda').then(eruda => eruda.default.init()); +} +``` + ## Configuration When initialization, a configuration object can be passed in.