Title: Invalid inline script
Last modified: September 29, 2022

---

# Invalid inline script

 *  Resolved [egornmore](https://wordpress.org/support/users/egornmore/)
 * (@egornmore)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/invalid-inline-script-2/)
 * Hello,
    After cloning or creating a new page/post I am getting a validation error:`
   invalid inline script`. The script contains the following code and the source
   is wp-includes.
 *     ```
       ( function() {
       		var query = document.location.search;
   
       		if ( query && query.indexOf( __SINGLE_QUOTED_STRING__ ) !== __INT__ ) {
       			window.name = __SINGLE_QUOTED_STRING__;
       		}
   
       		if ( window.addEventListener ) {
       			window.addEventListener( __SINGLE_QUOTED_STRING__, function() { window.name = __SINGLE_QUOTED_STRING__; }, false );
       		}
       	}());
       ```
   
 * I can get rid of that error by reinstalling the AMP plugin, but doing it every
   time is a little annoying.
    -  This topic was modified 3 years, 8 months ago by [egornmore](https://wordpress.org/support/users/egornmore/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Finvalid-inline-script-2%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/invalid-inline-script-2/#post-16055813)
 * Hello [@egornmore](https://wordpress.org/support/users/egornmore/)
 * Thank you for contacting us, The script you mentioned is added by [wp_post_preview_js()](https://developer.wordpress.org/reference/functions/wp_post_preview_js/)
   which should only be added on post preview.
 * AMP plugins marks preview script as [dev mode](https://github.com/ampproject/amp-wp/blob/develop/includes/amp-helper-functions.php#L1684-L1690),
   you can only see those scripts when you are tring to preview a post.
 * I don’t see any reason for that script to appear on published post, but in case
   your cache plugin is creating page cache when you try preview a post, the scrpt
   may appear.
 * Can you please try clearing page cache when you publish a post, or try to publish
   post without previewing it.
 * Hope this helps!
 *  Thread Starter [egornmore](https://wordpress.org/support/users/egornmore/)
 * (@egornmore)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/invalid-inline-script-2/#post-16055918)
 * Made some tests and you are right, preview mode causing an issue. Maybe that 
   can be fixed with a sanitizer to disable `wp_post_preview_js` validation or another
   workaround?
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/invalid-inline-script-2/#post-16055922)
 * We’re intentionally marking this script as being “PX-verified” when in dev mode:
   [https://github.com/ampproject/amp-wp/pull/6680](https://github.com/ampproject/amp-wp/pull/6680)
 * The script is needed by WordPress core.
 * If you access the page logged-out (i.e. not in post preview), then the script
   won’t be on the page.
 * If you don’t want it to show up at all, you could remove it yourself as well:
 *     ```
       remove_action( 'wp_head', 'wp_post_preview_js', 1 )
       ```
   
 *  Thread Starter [egornmore](https://wordpress.org/support/users/egornmore/)
 * (@egornmore)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/invalid-inline-script-2/#post-16056016)
 * [@westonruter](https://wordpress.org/support/users/westonruter/)
    Removing an
   action works for me, I can enable and disable it to clear errors, thank you!

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

The topic ‘Invalid inline script’ 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

 * [sanitizer](https://wordpress.org/support/topic-tag/sanitizer/)
 * [validation](https://wordpress.org/support/topic-tag/validation/)

 * 4 replies
 * 3 participants
 * Last reply from: [egornmore](https://wordpress.org/support/users/egornmore/)
 * Last activity: [3 years, 8 months ago](https://wordpress.org/support/topic/invalid-inline-script-2/#post-16056016)
 * Status: resolved