Title: Custom JavaScript is not allowed
Last modified: January 6, 2020

---

# Custom JavaScript is not allowed

 *  [Sanjeet Sagar](https://wordpress.org/support/users/rohaan9/)
 * (@rohaan9)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/custom-javascript-is-not-allowed-13/)
 * i don’t know why this error is showing. when i validate amp its showing Custom
   JavaScript is not allowed. below is code which loading as custom javascript.
 * Website Mode: Standard
 * `<script>document.addEventListener( "DOMContentLoaded", function() { document.
   write = function( text ) { throw new Error( "[AMP-WP] Prevented document.write()
   call with: " + text ); }; } );</script>`
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fcustom-javascript-is-not-allowed-13%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  [Renee Johnson](https://wordpress.org/support/users/reneesoffice/)
 * (@reneesoffice)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/custom-javascript-is-not-allowed-13/#post-12302688)
 * [@rohaan9](https://wordpress.org/support/users/rohaan9/) thanks for opening a
   topic. Since you’re using the plugin in Standard mode, this script is added as
   part of the default behavior of the plugin when it detects excessive CSS on your
   AMP page. When running the homepage through the [AMP validator](https://validator.ampproject.org/),
   note that your page is serving around 75kb of CSS when the AMP limit is 50kb.
 * In `Standard` mode, the excessive CSS will be _kept_ to prevent the styles on
   the page from breaking, but the plugin will remove the `amp` attribute and add
   the script you referenced to prevent the page from breaking in a particular scenario(
   when [<amp-live-list>](https://amp.dev/documentation/components/amp-live-list/)
   is present).
 * The page still makes use of AMP components and all other invalid markup is _removed_(
   reference the validation pages in the plugin for more detail). You’ll get the
   benefits of speed that AMP provides, but since the page is invalid it won’t be
   eligible for prerendering in search results. To pass validation, consider reducing
   the amount of CSS on the page.

Viewing 1 replies (of 1 total)

The topic ‘Custom JavaScript is not allowed’ 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/)

## Tags

 * [custom javascript](https://wordpress.org/support/topic-tag/custom-javascript/)

 * 1 reply
 * 2 participants
 * Last reply from: [Renee Johnson](https://wordpress.org/support/users/reneesoffice/)
 * Last activity: [6 years, 5 months ago](https://wordpress.org/support/topic/custom-javascript-is-not-allowed-13/#post-12302688)
 * Status: not resolved