Title: Non working embed code
Last modified: September 1, 2016

---

# Non working embed code

 *  Resolved [Spectoos](https://wordpress.org/support/users/spectoos/)
 * (@spectoos)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/non-working-embed-code/)
 * Hi Frank,
    I’d like to use this embed code on my site, but it breaks …
 * <iframe id=”intercom_map_iframe” src=”” frameborder=”0″ height=”600″ width=”800″
   ></iframe><script>(function(){var d = document.getElementById(‘intercom_map_iframe’).
   contentWindow.document;d.open().write(‘<body onload=”document.location.replace(\’
   [https://share.intercom.io/mnXeOFKMi-lg?embed=true](https://share.intercom.io/mnXeOFKMi-lg?embed=true)\’)”
   ></body>’);d.close();})();</script>
 * Please check [http://www.spectoos.com/map](http://www.spectoos.com/map)
 * Any ideas?
 * Thank you,
    Guy.
 * [https://wordpress.org/plugins/autoptimize/](https://wordpress.org/plugins/autoptimize/)

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

 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/non-working-embed-code/#post-7629929)
 * you could wrap that entire block in noptimize-tags (see FAQ) or add `intercom_map_iframe`
   to the comma-separated JS optimization exclusion list?
 * frank
 *  Thread Starter [Spectoos](https://wordpress.org/support/users/spectoos/)
 * (@spectoos)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/non-working-embed-code/#post-7629935)
 * Thanks Frank,
    I’ve added intercom_map_iframe, to the comma-separated list but
   it still doesn’t work …
 * Cheers,
    Guy.
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/non-working-embed-code/#post-7629939)
 * well, then you could go for the noptimize-approach? 🙂
 *  Thread Starter [Spectoos](https://wordpress.org/support/users/spectoos/)
 * (@spectoos)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/non-working-embed-code/#post-7629940)
 * OK, <!– noptimize –> solved it!
 * Cheers,
    Guy.
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/non-working-embed-code/#post-7629942)
 * I see
 * > 11:57:30.484 SyntaxError: unterminated string literal map:65:105
 * on my browser’s console, so that confirms the JS has been excluded from optimization,
   but there seems to be a problem with it?
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/non-working-embed-code/#post-7629943)
 * ah … just a sec, think I know what is happening …
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/non-working-embed-code/#post-7629947)
 * ok, so AO injects the js before the `</body>`-tag. your JS has that tag in it,
   so AO injects the JS inside your code.
 * so, try changing it into:
 *     ```
       <iframe id="intercom_map_iframe" src="" frameborder="0" height="600" width="800"></iframe><script>(function(){var d = document.getElementById('intercom_map_iframe').contentWindow.document;
       d.open().write('<body onload="document.location.replace(\'https://share.intercom.io/mnXeOFKMi-lg?embed=true\')"></bo'+'dy>');d.close();})();</script>
       ```
   
 * so `</body>');` becoming `</bo'+'dy>');`
 * frank
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/non-working-embed-code/#post-7629951)
 * ah, didn’t see you earlier message, noptimize FTW! 🙂
 *  Thread Starter [Spectoos](https://wordpress.org/support/users/spectoos/)
 * (@spectoos)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/non-working-embed-code/#post-7630022)
 * 🙂
    Thanks Frank for your help!

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

The topic ‘Non working embed code’ is closed to new replies.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [Spectoos](https://wordpress.org/support/users/spectoos/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/non-working-embed-code/#post-7630022)
 * Status: resolved