# Display a loading spinner when clicking a linked button 

**URL:** <https://forum.wixstudio.com/t/display-a-loading-spinner-when-clicking-a-linked-button/8410>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [January 24, 2022, 3:32am UTC](https://forum.wixstudio.com/t/display-a-loading-spinner-when-clicking-a-linked-button/8410 "2022-01-24T03:32:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![conrackx](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/conrackx/32/31862_2.png) [@conrackx](https://forum.wixstudio.com/u/conrackx)\
**Post date:** [January 24, 2022, 3:32am UTC](https://forum.wixstudio.com/t/display-a-loading-spinner-when-clicking-a-linked-button/8410/1 "2022-01-24T03:32:02Z")

</div>

Hello guys, as said in the title i want my site to display a loading spinner when users click some buttons linked to a dynamic page, this is to provide visual feedback that indeed something is happening because there’s an awkward but short delay in the loading process.

Problem is that whenever i add the onClick() that displays the spinner (html custom element), the link stops working altogether. If you guys can help me achieve my goal that would be great, and if you have a better solution i’ll be glad to read through it.

Just in case you are wondering about the loading time, it’s 2 or 3 seconds long even though it’s an extremely small proof of concept site: 2 small static pages and 2 dynamic pages linked to a 6 entries long dataset. Thanks for everything in advance.

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [January 24, 2022, 8:14am UTC](https://forum.wixstudio.com/t/display-a-loading-spinner-when-clicking-a-linked-button/8410/2 "2022-01-24T08:14:14Z")

</div>

The onClick() overrides the button’s link which is why the link stops working.

In any case, it makes more sense to first redirect to the dynamic page (via the button’s link), and then have a spinner on the dynamic page.

---

<div class="post-metadata">

**Author:** ![conrackx](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/conrackx/32/31862_2.png) [@conrackx](https://forum.wixstudio.com/u/conrackx)\
**Post date:** [January 24, 2022, 9:58am UTC](https://forum.wixstudio.com/t/display-a-loading-spinner-when-clicking-a-linked-button/8410/3 "2022-01-24T09:58:51Z")

</div>

@yisrael-wix indeed but this awkward delay happens before the redirection to the dynamic page, when the button is clicked absolutely nothing happens during these 3 seconds I mention, then the page appears and everything is already loaded so I don’t think a spinner would be useful by then.

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [January 24, 2022, 10:03am UTC](https://forum.wixstudio.com/t/display-a-loading-spinner-when-clicking-a-linked-button/8410/4 "2022-01-24T10:03:42Z")

</div>

Aha. But, what are you doing that causes the delay? Any code? If so then please share.

Sounds like what you need to do is to **not** use the Button’s link setting. Just set up an onClick() that will display a spinner, and then redirect to the dynamic page using [wixLocation.to()](https://www.wix.com/velo/reference/wix-location/to) .
