Tom-Bonnike/netlify-plugin-inline-critical-css

Plugin removes inline JavaScript from <head>

tomanistor opened this issue · 1 comments

When this plugin is activated in my build, it somehow removes inline JS from the <head> of my HTML files.

In the <head>, I have two Facebook pixel scripts, each with a different ID. The second one is erased, as though the plugin thinks it's duplicated CSS. It also erases part of the FB pixel code between a <noscript> tag, and the contents of another third-party <noscript> tag, so that both tags are left empty. I have tested this with Netlify deploys as well as the Netlify CLI local builds.

See examples below (actual IDs replaced with Xs and Ys):

Example of part of the file with the plugin not activated:

...
<script type=text/plain cookie-consent=tracking>
      !function(f,b,e,v,n,t,s)
      {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
      n.callMethod.apply(n,arguments):n.queue.push(arguments)};
      if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
      n.queue=[];t=b.createElement(e);t.async=!0;
      t.src=v;s=b.getElementsByTagName(e)[0];
      s.parentNode.insertBefore(t,s)}(window,document,'script',
      'https://connect.facebook.net/en_US/fbevents.js');
      fbq('init', 'XXXXXX');
      fbq('track', 'PageView');
    </script><noscript><img height=1 width=1 src="https://www.facebook.com/tr?id=XXXXXX&ev=PageView&noscript=1"></noscript><script type=text/plain cookie-consent=tracking>
      !function(f,b,e,v,n,t,s)
      {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
      n.callMethod.apply(n,arguments):n.queue.push(arguments)};
      if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
      n.queue=[];t=b.createElement(e);t.async=!0;
      t.src=v;s=b.getElementsByTagName(e)[0];
      s.parentNode.insertBefore(t,s)}(window,document,'script',
      'https://connect.facebook.net/en_US/fbevents.js');
      fbq('init', 'YYYYYY');
      fbq('track', 'PageView');
    </script><noscript><img height=1 width=1 src="https://www.facebook.com/tr?id=YYYYYY&ev=PageView&noscript=1"></noscript><noscript>ePrivacy and GPDR Cookie Consent by <a href=https://www.cookieconsent.com/ rel="nofollow noopener">Cookie Consent</a></noscript></head>
...

Example with the plugin activated:

...
<script type="text/plain" cookie-consent="tracking">
      !function(f,b,e,v,n,t,s)
      {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
      n.callMethod.apply(n,arguments):n.queue.push(arguments)};
      if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
      n.queue=[];t=b.createElement(e);t.async=!0;
      t.src=v;s=b.getElementsByTagName(e)[0];
      s.parentNode.insertBefore(t,s)}(window,document,'script',
      'https://connect.facebook.net/en_US/fbevents.js');
      fbq('init', 'XXXXXX');
      fbq('track', 'PageView');
    </script><noscript></noscript></head>
...

This plugin does nothing more than running https://github.com/addyosmani/critical on your HTML files. Please open an issue there.