Site icon Hip-Hop Website Design and Development

Add type to enqueued script inside plugin

So I don’t know if this is possible, but I have a question – We are integrating OneTrust and one of the requirements was to change <script type='text/javascript'> to <script type='text/plain>.

Inside one of the plugins that we have installed on WordPress, they have their file enqueued:

  wp_enqueue_script(
    'juicerembed',
    '//assets.juicer.io/embed-no-jquery.js',
    array('jquery'),
    false,
    false
  );

When the script is loaded, it loads it with no type which defaults to <script src='//assets.juicer.io/embed-no-jquery.js?ver=5.8.1' id='juicerembed-js'></script>.

Is there a way to hook or filter into a plugins enqueued scripts and add a type? Adding it inside the plugin directly will just get overwritten on next updates.

  1. Can you hook/filter possible?
  2. Do you deregister the script and then reregister?

All help will be appreciated!