Title: Simple javascript using amp-script not working
Last modified: November 18, 2022

---

# Simple javascript using amp-script not working

 *  Resolved [stevenbradley](https://wordpress.org/support/users/stevenbradley/)
 * (@stevenbradley)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/simple-javascript-using-amp-script-not-working/)
 * Hello, I’m trying to get the simple example on this page under the Virtual DOM
   heading:
 * [https://amp.dev/documentation/components/amp-script](https://amp.dev/documentation/components/amp-script)
 * to work on my wordpress site with the AMP plugin. For some reason it’s not working
   in wordpress but runs fine on non wordpress pages.
 * In the head area of the source code I see a few references to amp-script below:
 * **amp-script[nodom]
    amp-script[sandboxed]
 * <script src=”[https://cdn.ampproject.org/v0/amp-script-0.1.mjs&#8221](https://cdn.ampproject.org/v0/amp-script-0.1.mjs&#8221);
   async=”” custom-element=”amp-script” type=”module” crossorigin=”anonymous”></
   script>
    <script async nomodule src=”[https://cdn.ampproject.org/v0/amp-script-0.1.js&#8221](https://cdn.ampproject.org/v0/amp-script-0.1.js&#8221);
   crossorigin=”anonymous” custom-element=”amp-script”></script>`
 * It looks like it’s adding the required source library, not sure what the other
   code (in bold) means and suspect that is what is causing the issue?

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

 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/simple-javascript-using-amp-script-not-working/#post-16211702)
 * Hello [@stevenbradley](https://wordpress.org/support/users/stevenbradley/)
 * Thank you for contacting us, Can you please share the page where you implemented
   the amp-script?
 *  Thread Starter [stevenbradley](https://wordpress.org/support/users/stevenbradley/)
 * (@stevenbradley)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/simple-javascript-using-amp-script-not-working/#post-16213396)
 * Actually, after investigating it looks like the classic editor is the issue. 
   When I add the code in the text view it is fine, but when I switch the tab to
   visual it must remove it because when I switch back to text view the code is 
   gone.
 * So classic editor is removing the code dynamically when the view is toggled between
   text and visual.
 * Is there a working solution for this?
 *  Thread Starter [stevenbradley](https://wordpress.org/support/users/stevenbradley/)
 * (@stevenbradley)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/simple-javascript-using-amp-script-not-working/#post-16213407)
 * Also this is the code that is being removed by classic editor:
 * <amp-script src=”[http://example.com/my-script.js&#8221](http://example.com/my-script.js&#8221);
   width=”300″ height=”100″>
    <p>A single line of text</p> </amp-script>
 * It’s leaving the paragraph element and removing the surrounding amp-script tag.
 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/simple-javascript-using-amp-script-not-working/#post-16218827)
 * Hello [@stevenbradley](https://wordpress.org/support/users/stevenbradley/)
 * Thank you for identifying the issue, as we mentioned in your [previous support topic ](https://wordpress.org/support/topic/amp-carousel-html-being-removed-by-post-editor/#post-15775105)
   for amp-carousel classic editors is corrupting the amp tags and there is no solution
   for it.
 * We will recommend adding amp-script using a WordPress hook based on the location
   where you want them.
 *  Thread Starter [stevenbradley](https://wordpress.org/support/users/stevenbradley/)
 * (@stevenbradley)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/simple-javascript-using-amp-script-not-working/#post-16221236)
 * Alright, thanks. I will look into how to hack the classic editor as that is the
   real issue at this point and is not really an AMP plugin problem as I originally
   thought.
 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/simple-javascript-using-amp-script-not-working/#post-16248016)
 * [@stevenbradley](https://wordpress.org/support/users/stevenbradley/) As we didn’t
   receive a response I’ll mark this as resolved. Feel free to open a [new support topic](https://wordpress.org/support/plugin/amp/#new-post)
   if you require any further assistance.

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

The topic ‘Simple javascript using amp-script not working’ 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/)

 * 6 replies
 * 2 participants
 * Last reply from: [Milind More](https://wordpress.org/support/users/milindmore22/)
 * Last activity: [3 years, 6 months ago](https://wordpress.org/support/topic/simple-javascript-using-amp-script-not-working/#post-16248016)
 * Status: resolved