# Wordpress plugin script double ID attribute

**URL:** <https://community.hubspot.com/t/wordpress-plugin-script-double-id-attribute/24960>\
**Category:** APIs & Integrations\
**Tags:** developer-tools\
**Created:** [September 2, 2020, 8:21pm UTC](https://community.hubspot.com/t/wordpress-plugin-script-double-id-attribute/24960 "2020-09-02T20:21:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![danny\_briskin](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/danny_briskin/32/28756_2.png) [@danny\_briskin](https://community.hubspot.com/u/danny_briskin)\
**Post date:** [September 2, 2020, 8:21pm UTC](https://community.hubspot.com/t/wordpress-plugin-script-double-id-attribute/24960/1 "2020-09-02T20:21:48Z")

</div>

Hello,

We are using Wordpress plugin for Hubspot ( **HubSpot All-In-One Marketing - Forms, Popups, Live Chat** )

And that plugin adds a Javascript to our pages, like :

`<script async defer id="hs-script-loader" type='text/javascript' src='//js.hs-scripts.com/2470523.js?integration=WordPress' id='leadin-script-loader-js-js'></script>`

There are 2 **id** attributes in this script:

1. hs-script-loader
2. leadin-script-loader-js-js

First one comes from

**leadin/src/class-assetsmanager.php** (enqueue\_script\_loader function)

while second one is from

**leadin/src/class-pagehooks.php** (add\_id\_to\_tracking\_code function)

It doesn’t look good to have 2 ids (even if it des not break anything)

Please fix.

Thank you!

---

<div class="post-metadata">

**Author:** ![WendyGoh](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/wendygoh/32/42320_2.png) [@WendyGoh](https://community.hubspot.com/u/WendyGoh)\
**Post date:** [September 4, 2020, 5:00am UTC](https://community.hubspot.com/t/wordpress-plugin-script-double-id-attribute/24960/2 "2020-09-04T05:00:16Z")

</div>

Hey [@danny\_briskin](https://community.hubspot.com/t5/user/viewprofilepage/user-id/142239),

I believe the both the id attributes:

1. hs-script-loader
2. leadin-script-loader-js-js

are required for the tracking and form to show up successful.

Is there a reason why your team had like to remove either one of the code?

If the intentional is to combine the ids as one, this is currently not possible.

---

<div class="post-metadata">

**Author:** ![danny\_briskin](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/danny_briskin/32/28756_2.png) [@danny\_briskin](https://community.hubspot.com/u/danny_briskin)\
**Post date:** [September 8, 2020, 3:24pm UTC](https://community.hubspot.com/t/wordpress-plugin-script-double-id-attribute/24960/3 "2020-09-08T15:24:09Z")

</div>

Hi @WendyGoh ,

The intention is to have a page that complies HTML standards. [W3C validator](https://validator.w3.org/) says “duplicate specification of attribute id”.

It does not sound logical to have it twice. Any parser should ignore second occurence.

---

<div class="post-metadata">

**Author:** ![WendyGoh](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/wendygoh/32/42320_2.png) [@WendyGoh](https://community.hubspot.com/u/WendyGoh)\
**Post date:** [September 10, 2020, 8:26am UTC](https://community.hubspot.com/t/wordpress-plugin-script-double-id-attribute/24960/4 "2020-09-10T08:26:45Z")

</div>

Hey [@danny\_briskin](https://community.hubspot.com/t5/user/viewprofilepage/user-id/142239),

Just an update from our team!

We understand that having the same attribute twice is technically not correct from the standard point of view.

In the practice, what browsers do is ignoring the second attribute they find while they are parsing the DOM Element. In this case `leadin-script-loader-js-js` should be ignored by the browser.

While I do not have a deadline, we are aware of this issue and would study the possibility of removing the second id `id='leadin-script-loader-js-js'` in future releases.

---

<div class="post-metadata">

**Author:** ![d2roth](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/d2roth/32/5125_2.png) [@d2roth](https://community.hubspot.com/u/d2roth)\
**Post date:** [September 29, 2020, 8:36pm UTC](https://community.hubspot.com/t/wordpress-plugin-script-double-id-attribute/24960/5 "2020-09-29T20:36:49Z")

</div>

I ran into this same issue and I am wondering if there is a reason not to use teh following:

`$tag = str_replace( "id='leadin-script-loader-js-js'", "", $tag);`

So the code in class-pagehooks.php could become:

```lia-code-sample
$tag = str_replace( '<script', '<script async defer ', $tag );
$tag = str_replace( "id='leadin-script-loader-js-js'", 'id="hs-script-loader"', $tag);

```

I made the modification via a mu-plugin as follows:

```lia-code-sample
<?php
add_filter( 'script_loader_tag', 'dd_fix_hs_duplicate_id_issue', 20, 3 );

function dd_fix_hs_duplicate_id_issue( $tag, $handle, $src ) {
 if( !class_exists( "\Leadin\AssetsManager" ) )
 return $tag;

 if ( \Leadin\AssetsManager::TRACKING_CODE === $handle ) {
 $tag = str_replace( "id='leadin-script-loader-js-js'", "", $tag);
 }
 return $tag;
}

```
