Hello @enricobt
You can use the amp-script component to add custom javascript on your site.
The amp-script copies the component’s children to a virtual DOM. so the code will execute in Worked DOM.
As I checked the script you attached is dependent on jquery, Presently, libraries like jQuery will not work with amp-script without modification, as they use unsupported DOM APIs. You can learn mode about it here
The script creates a form dynamically and attaches it to the page, it also has code for validation and other functionalities, I will recommend checking if you can add the form without javascript that is using just PHP code. or using WP hooks.
If by popup you mean lightbox then you could use amp-lightbox
without any custom JS.
Another possibility is the Newspack Popups plugin: https://github.com/Automattic/newspack-popups
Hi
thanks for your reply. Actually, the solution suggested by amp-script needs some effort on programming and I’m not sure if I have the knowledge to make it.
The solution with newspack-popups cannot work in my current setup, because it requires either the newspack theme or some other plugin, such as Gutemberg, that I’m not currently using.
Do you know if there is any other plugin that creates popup’s in AMP environment?
Regards
Enrico
Hello @enricobt
I will suggest using AMP Enhancer plugin it has a feature to add Popup on AMP pages.
1. Install plugin normally as you do then goto AMP -> AMP Enhancer -> Click on the tab named “Features”
2. Enable Popup feature
3. You can configure popup’s from the settings icons next to the toggle button or goto AMP->Popup
Hi
I tested this plugin and it seems to be fine. I created an HTML form, without Javascript, and it works.
The only thing is that is not responsive, as on mobiles the popup window goes out of the mobile display.
I will try to change CSS and see if it can go and fit on mobile screens too.
Many thanks again for your support.
Regards
Enrico
Good to know it helped, yup some CSS tweak might be needed as per your site.
Feel free to open a new support topic if you need further assistance, also leave your thoughts on using the AMP plugin, We love to hear your feedback