Form Module: Remove JS assets inserted into page
Created 3 years ago by finnito

Hey all,

I'm using the Forms Module to display a basic contact form:

  • Name (text field)
  • Email (text field)
  • Message (textarea field)

And I am using the following code to embed it in the page:

{{ form('forms::contact').setOption('prefix', 'contact_').get()|raw }}

When the page loads it seems that the field types have inserted a bunch of JS resources via the scripts.js asset collection, however, I don't think that they actually do anything useful in the case of my form. How can I remove these assets from the collection so that I do not bloat my page with JS that is not doing anything?

NB: The scripts are: translations.js, inputmask.js, binding.js, masking extensions, and a heap of others.


finnito  —  3 years ago Best Answer

Fixed this by using a different asset collection for themeing scripts, that way I didn’t have to include the scripts.js collection that is often full of unnecessary files from all the field types.