Title: Invalid scripts
Last modified: November 22, 2021

---

# Invalid scripts

 *  Resolved [Anuj](https://wordpress.org/support/users/anujmakhloga/)
 * (@anujmakhloga)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/invalid-scripts/)
 * Hi,
 * I’ve got invalid script errors lately with some plugins (I am trying to sort 
   it out with the respective support team). But there is an invalid script error
   regarding an ad placed via widgets which is a non-amp version ad.
 * For all details and images, please visit here > [msg](https://wordpress.org/support/topic/amp-validation-error-with-generatepress-theme/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Fellyph Cintra](https://wordpress.org/support/users/fellyph/)
 * (@fellyph)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/invalid-scripts/#post-15091175)
 * Hi [@anujmakhloga](https://wordpress.org/support/users/anujmakhloga/),
 * Thanks for contacting us, I hope that you had a nice weekend. Let me know which
   widget and the code you are using on your sidebar, and I can suggest some solutions.
 * A reminder from previous conversation, AMP does not allow custom JavaScript, 
   at least in the traditional way. Let’s say you want to display non-amp ads on
   a non-amp: page it is fine. The script will run normally in a non-AMP, at the
   AMP version the script tag will be removed, and a warning will be triggered, 
   but you mark as solved, because this is an expected behavior. And for the AMP
   version, you use your AMP compatible ads plugin.
 * Warnings are different from errors, warning the script will be removed, and your
   page continues valid.
 * But in the case you need to use this script in AMP version. You’ll need to find
   an alternative to using custom JS.
 * Three options:
 * – Use an AMP component that implements the desired functionality.
    Develop an
   alternative that works with JS turned off. While the AMP plugin removes custom
   JS it will at the same time unwrap noscript tags, so if you have fallback behavior
   for when JS is turned off in the browser, then this will become the baseline 
   AMP experience. – Refactor your JS to be containable in amp-script. – Serve the
   functionality in an iframe via amp-iframe.
 *  Thread Starter [Anuj](https://wordpress.org/support/users/anujmakhloga/)
 * (@anujmakhloga)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/invalid-scripts/#post-15092253)
 * Hi,
 * Thanks. I have a question, though.
 * After reaching other plugin support, I’ve realized that all those “invalid scripts”
   are occurring for the backend only (I am not 100% sure, but most of them said
   about their plugins). But I can’t understand what amp has to do with the admin
   panel? I don’t know if my question is correct, but this is what I have got so
   far.
 * Regarding the “wp-include” script-
 * Following is the ad code I am using in an Html widget in the sidebar. It is only
   valid for non-amp –
 *     ```
       <blockquote><p><script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-36xxxxxxxxx" crossorigin="anonymous"></script><br>
       <!-- Sidebar (Non Amp) --><br>
       <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-36xxxxxxxxxx" data-ad-slot="70xxxxxxxxx" data-ad-format="auto" data-full-width-responsive="true"></ins><br>
       <script><br />
            (adsbygoogle = window.adsbygoogle || []).push({});<br />
       </script></p>
       ```
   
 * > The script will run normally in a non-AMP, at the AMP version the script tag
   > will be removed, and a warning will be triggered, but you mark as solved, because
   > this is an expected behavior.
 * I didn’t get everything, but then should I update all those errors as being “
   removed”?
    Sorry if I am repeating the same question.
 *  [Fellyph Cintra](https://wordpress.org/support/users/fellyph/)
 * (@fellyph)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/invalid-scripts/#post-15095697)
 * Hi [@anujmakhloga](https://wordpress.org/support/users/anujmakhloga/)
 * Thanks for getting back, the fact over back-end only is because when you logged
   some plugins will load scripts to enable functionalities for admins only and 
   the validation will catch those scripts, but those scripts won’t be loaded to
   normal users or Googlebot for example.
 * Yes, if you want to display those ads only for non-AMP you can remove this validation
   warning and ignore it. As I mentioned previously, warnings don’t block your page
   being AMP valid, are just a call for you to check if the pages are working as
   expected.
 * If you want to remove the warning,
    you can go to the warning caused by the widget
   that you mentioned. Select the pages that are triggering the warning and mark
   to forget it
 * ![](https://i0.wp.com/i.imgur.com/Ha6l1Uz.png?ssl=1)
 *  Thread Starter [Anuj](https://wordpress.org/support/users/anujmakhloga/)
 * (@anujmakhloga)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/invalid-scripts/#post-15096071)
 * Great! Thank you for all your support.
 * Have a good day 🙂
 *  [Fellyph Cintra](https://wordpress.org/support/users/fellyph/)
 * (@fellyph)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/invalid-scripts/#post-15096400)
 * You are Welcome [@anujmakhloga](https://wordpress.org/support/users/anujmakhloga/),
   feel free to get back if you have any question.
 * There is a video series with Alberto Medina with some useful information if you
   would like to learn more about the plugin:

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Invalid scripts’ is closed to new replies.

 * ![](https://ps.w.org/amp/assets/icon.svg?rev=2527602)
 * [AMP](https://wordpress.org/plugins/amp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amp/)
 * [Active Topics](https://wordpress.org/support/plugin/amp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amp/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Fellyph Cintra](https://wordpress.org/support/users/fellyph/)
 * Last activity: [4 years, 4 months ago](https://wordpress.org/support/topic/invalid-scripts/#post-15096400)
 * Status: resolved