Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
gnat authored Nov 14, 2023
1 parent 1f43fbe commit b19cf6d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,12 @@ Append / Prepend elements.

## 🔎 Technical FAQ
* Can I locally scope functions to `<script>` ?
* The recommended way to scope a function is to place it in an event, ex: `me().on('click', ev => { ... })`
* The 2nd recommended way is to avoid scoping functions and keep a `common.js` file for global functions.
* The 3rd way is using `<script type="module">` but `me()` will no longer see `parentElement` so, an explicit selector is required, ex: `me(".mybutton")`
* This is a tradeoff solution, but may be most appropriate in some circumstances.
* Recommended: Scope inside an event.
* `me().on('click', ev => { /* add and call function here */ })`
* Alternative: Use `<script type="module">`
* Tradeoff: `me()` will no longer see `parentElement` so, an explicit selector is required: `me(".mybutton")`
* Alternative: Keep a `common.js` file for global functions.
* Alternative: Uniquely name your function.

## <a name="plugins"></a>🔌 Adding a function

Expand Down

0 comments on commit b19cf6d

Please sign in to comment.