• Resolved enricobt

    (@enricobt)


    Hi
    I know that javascript are blocked by AMP but I would need to add a code (attached below) to activate the MAILUP popup in all articles of my site.
    The code works fine in the pages, such as in the homepage, because I excluded pages in AMP advanced settings (so content pages are not enabled in AMP), but of course, it’s blocked in all thousands of articles available in my blog.
    I definitely want to avoid to exclude content articles from AMP too, because this will penalize site visibility and performances.

    Do you have any suggestions on how to activate this javascript in articles too?
    Many thanks in advance for your help

    Regards
    Enrico
    —-

    This is the script that i put in the /bosy section of all pages:
    <script type=”text/javascript” id=”src-mltchnl” src=”https://form-multichannel.emailsp.com/forms/3741/match/4edf9d49-3650-47d5-91de-4774004937ef/140272″></script&gt;
    <div id=”frm-mltchnl”></div>

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Milind More

    (@milindmore22)

    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.

    Plugin Author Weston Ruter

    (@westonruter)

    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

    Thread Starter enricobt

    (@enricobt)

    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

    Plugin Support Milind More

    (@milindmore22)

    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

    Thread Starter enricobt

    (@enricobt)

    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

    Plugin Support Milind More

    (@milindmore22)

    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

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Java script in AMP’ is closed to new replies.