---
title: "Discussion on \"🛑 Why You Should Avoid the onclick Attribute in Your Code\" | Hashnode"
description: "Discussion on \"🛑 Why You Should Avoid the onclick Attribute in Your Code\". Hey everyone! It's been a while since I wrote my last article. But here I am with another topic that might be informational to you 🙂.\nThis time I am writing about why you should avoid the onclick attribute in your HTML and JavaScript code.\n\n\nThis ar..."
url: "https://hashnode.com/posts/why-you-should-avoid-the-onclick-attribute-in-your-code/6395d8b8c53c1fb85a9d9fd4"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [🛑 Why You Should Avoid the onclick Attribute in Your Code](https://blog.usmans.me/why-you-should-avoid-the-onclick-attribute-in-your-code?utm_source=hashnode&utm_medium=feed)

Hey everyone! It's been a while since I wrote my last article. But here I am with another topic that might be informational to you 🙂. This time I am writing about why you should avoid the onclick attribute in your HTML and JavaScript code. This ar...

Dec 11, 2022 · 4 min read · blog.usmans.me  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#html5](https://hashnode.com/tag/html5)
-   [#html](https://hashnode.com/tag/html)
-   [#web-development](https://hashnode.com/tag/web-development)
-   [#webdev](https://hashnode.com/tag/webdev)

## Written by

[Usman Sabuwala](https://hashnode.com/@usmanwrites)

@usmanwrites · India

  
[View profile](https://hashnode.com/@usmanwrites)

Learning web development, running a YouTube channel

I am a full stack developer, YouTuber and blogger!

## Responses 5

Markdown supported · ⌘↵ to post

[Lovepreet Singh](https://hashnode.com/@Singh5713)

[Dec 12, 2022](https://hashnode.com/posts/why-you-should-avoid-the-onclick-attribute-in-your-code/6395d8b8c53c1fb85a9d9fd4/comment/6396c90115750808b269ebda)

Yo, Wasn't aware about this. Thanks

👉 **Also, Guys you react and check my latest blog. Tried to contribute for A simple project for beginners** [lovepreet.hashnode.dev/url-shorteners-a-practical…](https://lovepreet.hashnode.dev/url-shorteners-a-practical-approach-mini-project)

Will write more advanced Soon

[Md Shakib Ahmed](https://hashnode.com/@mdshakibahmed)

[Dec 11, 2022](https://hashnode.com/posts/why-you-should-avoid-the-onclick-attribute-in-your-code/6395d8b8c53c1fb85a9d9fd4/comment/6396183b90dd49222205f858)

Thank you so much given such a piece of valuable information. it's really helpful for me! I appreciate the author of this post sharing something special. I am super excited to share that I have found Graphicly!

[Graphicly](https://graphicsly.net/) is an all-in-one plugin for graphics management, image cropping, and image optimization. Graphicly lets you easily download and use images from the web,

whether you are on a website or on your WordPress site. With our powerful API, you can create customized libraries of images that integrate seamlessly into your theme’s header.

as a result of reading this post. I'm getting to save your profile in my favorite list. 🥰

[Amirah Nasihah](https://hashnode.com/@amirahnasihah)

[Dec 11, 2022](https://hashnode.com/posts/why-you-should-avoid-the-onclick-attribute-in-your-code/6395d8b8c53c1fb85a9d9fd4/comment/639602d390dd49222205f60b)

Thanks. Understand a lot!

[Raja Junaid Farooq](https://hashnode.com/@Junaidprogrammer)

[Dec 11, 2022](https://hashnode.com/posts/why-you-should-avoid-the-onclick-attribute-in-your-code/6395d8b8c53c1fb85a9d9fd4/comment/6395f99b15750808b269d396)

Thank you so much Usman for sharing great ideas. It's very helpful for me and I tried it and Boom. Keep Growing and Keep Sharing.
