Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New rule: Ban top-level querying in module. #228

Open
koddsson opened this issue Mar 29, 2022 · 0 comments
Open

New rule: Ban top-level querying in module. #228

koddsson opened this issue Mar 29, 2022 · 0 comments

Comments

@koddsson
Copy link
Contributor

Querying should be wrapped in event listeners such as document.addEventListener('DOMContentLoaded', ...) or a Web Component.

👎🏻 Examples of bad code.

const el = document.querySelector('.my-element')

👍🏻 Example of good code.

document.addEventListener('DOMContentLoaded', function() {
  const el = document.querySelector('.my-element')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant