# Module data attribute changing on page load

**URL:** <https://community.hubspot.com/t/module-data-attribute-changing-on-page-load/127066>\
**Category:** CMS Development\
**Created:** [February 28, 2025, 12:03am UTC](https://community.hubspot.com/t/module-data-attribute-changing-on-page-load/127066 "2025-02-28T00:03:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajatnb](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ajatnb/32/104126_2.png) [@ajatnb](https://community.hubspot.com/u/ajatnb)\
**Post date:** [February 28, 2025, 12:03am UTC](https://community.hubspot.com/t/module-data-attribute-changing-on-page-load/127066/1 "2025-02-28T00:03:31Z")

</div>

I’m noticing that modules, when first added to a page, load in a container with data attribute [data-hs-cos-type=“custom\_widget”] which then changes to [data-hs-cos-type=“module”] after page reload. i would expect it to always load in [data-hs-cos-type=“module”]. any ideas on why this is happening?

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [February 28, 2025, 6:57pm UTC](https://community.hubspot.com/t/module-data-attribute-changing-on-page-load/127066/2 "2025-02-28T18:57:07Z")

</div>

Hi, @ajatnb 👋 Thanks for your question. I couldn’t find any matching post for this one. I’d like to invite some of our community members to the conversation — hey @evaldas @GiantFocal @BarryGrennan have you noticed this behaviour in any of your own work?

Best,

Jaycee

---

<div class="post-metadata">

**Author:** ![GRajput](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/grajput/32/102020_2.png) [@GRajput](https://community.hubspot.com/u/GRajput)\
**Post date:** [September 28, 2026, 10:11am UTC](https://community.hubspot.com/t/module-data-attribute-changing-on-page-load/127066/3 "2026-09-28T10:11:55Z")

</div>

Hi @ajatnb

Please add the following script inside the tag to update the data-hs-cos-type attribute to module when the page loads.  
window.addEventListener(‘load’, () =\> {  
const element = document.querySelector(‘’);  
if (element) {  
element.setAttribute(‘data-hs-cos-type’, ‘module’);  
}  
});

Please replace the placeholder with the appropriate class or ID of the element.

Thanks!
