# Removing jquery from advanced form embed code

**URL:** <https://community.hubspot.com/t/removing-jquery-from-advanced-form-embed-code/50538>\
**Category:** CMS Development\
**Tags:** forms\
**Created:** [January 28, 2022, 12:20pm UTC](https://community.hubspot.com/t/removing-jquery-from-advanced-form-embed-code/50538 "2022-01-28T12:20:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![matttunney](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/matttunney/32/18373_2.png) [@matttunney](https://community.hubspot.com/u/matttunney)\
**Post date:** [January 28, 2022, 12:20pm UTC](https://community.hubspot.com/t/removing-jquery-from-advanced-form-embed-code/50538/1 "2022-01-28T12:20:43Z")

</div>

Hello,

Can someone please provide a little more clarity on the advanced form embed script please?

I am trying to remove jQuery from my site and hoping to remove jQuery calls on my form embed codes.

[https://legacydocs.hubspot.com/docs/methods/forms/advanced\_form\_options](https://legacydocs.hubspot.com/docs/methods/forms/advanced_form_options)

If I am no longer using jQuery do i still need to call `$form` on the `onFormReady` callback function to manipulate the form?

Right now i use jQuery to pass across the referrer value:

```lia-code-sample
onFormReady: function($form) {
 $('input[name="form_page"]').val(document.referrer).change();
})

```

Can I adjust this to the following without issue:

```lia-code-sample
onFormReady: function() {
 var form_page = document.getElementsByName("form_page")[0];
 form_page.value = document.referrer;
 form_page.dispatchEvent(new Event('input', { bubbles: true }));
})

```

Thanks

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [January 31, 2022, 7:32am UTC](https://community.hubspot.com/t/removing-jquery-from-advanced-form-embed-code/50538/2 "2022-01-31T07:32:57Z")

</div>

Hi @matttunney ,

Yes you can! Or switch to the window events that are available:

```lia-code-sample
 window.addEventListener('message', event => {
 if (event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormReady') {
 // Your code here.
 }
 });

```

If you want to change the value of anything other than a radio or checkbox input, you can use the dispatchEvent. If you want to change the value of a checkbox or radio input, use click instead:

```lia-code-sample
if (input.type === 'checkbox' || input.type === 'radio') {
 input.click();
} else {
 input.value = value;
 input.dispatchEvent(new Event('input', { bubbles: true }));
}

```

---

<div class="post-metadata">

**Author:** ![matttunney](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/matttunney/32/18373_2.png) [@matttunney](https://community.hubspot.com/u/matttunney)\
**Post date:** [February 14, 2022, 3:19pm UTC](https://community.hubspot.com/t/removing-jquery-from-advanced-form-embed-code/50538/3 "2022-02-14T15:19:04Z")

</div>

That is perfect  
Thanks for your response and examples
