Title: Include Option to Include AMP-iframe Javascript Extension
Last modified: August 14, 2019

---

# Include Option to Include AMP-iframe Javascript Extension

 *  [daneloctober](https://wordpress.org/support/users/daneloctober/)
 * (@daneloctober)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/include-option-to-include-amp-iframe-javascript-extension/)
 * Hi!
 * So I noticed that the amp iframe javascript extension is not always loaded. I
   need to force it, since I’m loading an iframe, and I need it on every page. So
   I added this to the HTML head of the AMP for WP options:
    <script custom-element
   =”amp-iframe” src=”[https://cdn.ampproject.org/v0/amp-iframe-latest.js&#8221](https://cdn.ampproject.org/v0/amp-iframe-latest.js&#8221);
   async></script>
 * In the pages where the script isn’t loaded by the plugin, it’s fine, but for 
   the pages that load it automatically, I naturally get an error because it’s loaded
   twice. It’s not a problem now, but I get a warning that it will soon be a problem.
 * Is there a way currently to make it load automatically? Please please help. Thank
   you!

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

 *  Plugin Author [Ahmed Kaludi](https://wordpress.org/support/users/ahmedkaludi/)
 * (@ahmedkaludi)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/include-option-to-include-amp-iframe-javascript-extension/#post-11840402)
 * So Is it the iframe or AMP-Iframe that you are inserting (also share the code
   if possible) and where exactly?
 * So I will also try to re-create it and If the issue occurs which I am sure it
   will, then I will try to solve it and release immediately.
 *  Thread Starter [daneloctober](https://wordpress.org/support/users/daneloctober/)
 * (@daneloctober)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/include-option-to-include-amp-iframe-javascript-extension/#post-11844143)
 * Hi Ahmed!
 * Here’s the code I insert at the bottom of my pages:
 *     ```
       <amp-iframe width="200" height="300"
           sandbox="allow-scripts allow-same-origin allow-forms"
           layout="responsive"
           frameborder="0"
           src="https://youcanbefound.com/wp-content/js/thc_contact.html">
       	<amp-img layout = "fill" src = "/wp-content/uploads/2019/08/loading.gif" placeholder></amp-img>
       </amp-iframe>
       ```
   
 * Now, in the past I didn’t use an image placeholder. So when pages were not long
   enough, the iframe doesn’t load, and the amp for wp plugin doesn’t load the amp
   iframe extension library ([https://cdn.ampproject.org/v0/amp-iframe-latest.js](https://cdn.ampproject.org/v0/amp-iframe-latest.js)).
   Now, since I added the placeholder, I don’t need the content requirement anymore.
   But it still won’t show because amp for wp doesn’t load the amp iframe extension
   library for all pages (I’m assuming it only loads it for pages with long enough
   content).
 * So is there a way to have it load all the time? I have to force it now, but for
   pages that load it automatically, it loads twice.
 *  Plugin Author [Ahmed Kaludi](https://wordpress.org/support/users/ahmedkaludi/)
 * (@ahmedkaludi)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/include-option-to-include-amp-iframe-javascript-extension/#post-11848352)
 * I understood your issue. We can definitely fix this but I just need one last 
   answer:
 * Where exactly are you inputting the code? (Classic Editor, Gutenberg code module,
   AMP page builder, Widget or somewhere else?)
 * Kindly provide the screenshot of the input so I can be 100% accurate with the
   solution.
 *  Thread Starter [daneloctober](https://wordpress.org/support/users/daneloctober/)
 * (@daneloctober)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/include-option-to-include-amp-iframe-javascript-extension/#post-11852060)
 * Hi Ahmed!
 * I added the script via an action hook in functions.php:
 *     ```
       add_action('amp_post_template_above_footer','contact_form_code');
   
       function contact_form_code() {
       	$contactscript = '<amp-iframe width="200" height="300"
           sandbox="allow-scripts allow-same-origin allow-forms"
           layout="responsive"
           frameborder="0"
           src="https://youcanbefound.com/wp-content/js/thc_contact.html">
       	<amp-img layout = "fill" src = "/wp-content/uploads/2019/08/loading.gif" placeholder></amp-img>
       </amp-iframe>';
   
       	echo $contactscript;
       }
       ```
   
 * Let me know if you need anything else.
 * Thank you!

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

The topic ‘Include Option to Include AMP-iframe Javascript Extension’ is closed 
to new replies.

 * ![](https://ps.w.org/accelerated-mobile-pages/assets/icon-256x256.png?rev=1693616)
 * [AMP for WP - Accelerated Mobile Pages](https://wordpress.org/plugins/accelerated-mobile-pages/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/accelerated-mobile-pages/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/accelerated-mobile-pages/)
 * [Active Topics](https://wordpress.org/support/plugin/accelerated-mobile-pages/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/accelerated-mobile-pages/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/accelerated-mobile-pages/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [daneloctober](https://wordpress.org/support/users/daneloctober/)
 * Last activity: [6 years, 7 months ago](https://wordpress.org/support/topic/include-option-to-include-amp-iframe-javascript-extension/#post-11852060)
 * Status: not resolved