Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Allow for exporting tagin as a module #10

Closed
Teraskull opened this issue Dec 4, 2021 · 1 comment
Closed

Allow for exporting tagin as a module #10

Teraskull opened this issue Dec 4, 2021 · 1 comment

Comments

@Teraskull
Copy link
Contributor

Solution:

Add export default to the tagin function:

export default function tagin(el, option = {}) {

Import the script as a module:

<script src="tagin.js" type="module"></script>

Then it is possible to import tagin inside a script:

import tagin from "tagin.js";

tagin(document.querySelector('.tagin'))

Reason:

This removes the current way of inline importing/using tagin inside HTML:

<script>
    tagin(document.querySelector('.tagin'))
</script>

Inline JS is generally considered bad practice.

Pros:

Easier to import a required function into an existing script file, if there will useful functions in the future.

Cons:

Internet Explorer does not support import. (Is that really a con though?)

@erwinheldy
Copy link
Owner

This issue was closed by the release of version 2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants