# Embedded Notebook not rendering on mobile?

**URL:** <https://talk.observablehq.com/t/embedded-notebook-not-rendering-on-mobile/1961>\
**Category:** Help\
**Created:** [May 8, 2019, 6:56pm UTC](https://talk.observablehq.com/t/embedded-notebook-not-rendering-on-mobile/1961 "2019-05-08T18:56:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![workplacestrat](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/workplacestrat/32/1735_2.png) [@workplacestrat](https://talk.observablehq.com/u/workplacestrat)\
**Post date:** [May 8, 2019, 6:56pm UTC](https://talk.observablehq.com/t/embedded-notebook-not-rendering-on-mobile/1961/1 "2019-05-08T18:56:52Z")

</div>

Hello,

I am working on a project that includes embedding notebooks into a static site, generated with docusaurus.

The embed workflow I am using is close to the one used in the jekyll examples, where I link to a js file as a module from within a Markdown document, and the js file imports the runtime and my notebook.

All is well on desktop, both on the localhost dev server and as deployed on s3.

But I cannot get the notebooks to show on mobile. Any theories on this one?

---

<div class="post-metadata">

**Author:** ![jashkenas](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/jashkenas/32/1778_2.png) [@jashkenas](https://talk.observablehq.com/u/jashkenas)\
**Post date:** [May 8, 2019, 7:13pm UTC](https://talk.observablehq.com/t/embedded-notebook-not-rendering-on-mobile/1961/2 "2019-05-08T19:13:03Z")

</div>

Can you link to an example of the failing embed, so that we can take a closer look?

---

<div class="post-metadata">

**Author:** ![workplacestrat](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/workplacestrat/32/1735_2.png) [@workplacestrat](https://talk.observablehq.com/u/workplacestrat)\
**Post date:** [May 8, 2019, 10:03pm UTC](https://talk.observablehq.com/t/embedded-notebook-not-rendering-on-mobile/1961/3 "2019-05-08T22:03:42Z")

</div>

@jashkenas

reproduced an example for you.

notebook: [https://observablehq.com/d/c345e74ae295df4a](https://observablehq.com/d/c345e74ae295df4a) (obviously it is not anything to do with the complexity of the notebook…)

url: [http://dlw52clseo7n8.cloudfront.net/docs/exampleEmbed.html](http://dlw52clseo7n8.cloudfront.net/docs/exampleEmbed.html)

this is a static page on s3, distributed on cloudfront and protected with a lamba@edge login function.

username: test  
pw: test

It is working for me on desktop, but not on mobile. I think it is something to do with the login feature because if I host on a public s3 bucket, I cannot reproduce the error.

the js module I call in the html doc is:

```
  import notebook from "https://api.observablehq.com/d/c345e74ae295df4a.js";

  const target = document.querySelector("#visual");
  const renders = {
    "helloWorld": "#helloWorld",

  };

  // BOILERPLATE
  import {Inspector, Runtime} from "https://cdn.jsdelivr.net/npm/@observablehq/runtime@3/dist/runtime.js";
  for (let i in renders) {
    let s = renders[i], a = s.match(/^\w+/);
    if (a) {
      renders[i] = document.createElement(a[0]);
      target.appendChild(renders[i]);
      if (a = s.match(/\.(\w+)$/))
        renders[i].className = a[1];
    }
    else
      renders[i] = document.querySelector(renders[i]);
  }
  Runtime.load(notebook, (variable) => {
    if (renders[variable.name]) {
      return new Inspector(renders[variable.name]);
    } else {
      return true; // uncomment to run hidden cells
    }
  });
```

---

<div class="post-metadata">

**Author:** ![bgchen](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/bgchen/32/784_2.png) [@bgchen](https://talk.observablehq.com/u/bgchen)\
**Post date:** [May 8, 2019, 10:51pm UTC](https://talk.observablehq.com/t/embedded-notebook-not-rendering-on-mobile/1961/4 "2019-05-08T22:51:19Z")

</div>

It might be a Safari vs other browsers issue, since I’m getting the same CORS error on both mobile and desktop Safari when I visit your test site:

> Blocked [http://dlw52clseo7n8.cloudfront.net/js/helloWorld.js](http://dlw52clseo7n8.cloudfront.net/js/helloWorld.js) from asking for credentials because it is a cross-origin request.

(Chrome and Firefox seem to handle the page fine.) According to [this SO question](https://stackoverflow.com/questions/16824661/cors-request-not-working-in-safari), it looks like Safari is a little more finicky about CORS headers.

---

<div class="post-metadata">

**Author:** ![workplacestrat](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/workplacestrat/32/1735_2.png) [@workplacestrat](https://talk.observablehq.com/u/workplacestrat)\
**Post date:** [May 9, 2019, 12:23am UTC](https://talk.observablehq.com/t/embedded-notebook-not-rendering-on-mobile/1961/5 "2019-05-09T00:23:41Z")

</div>

This is very helpful - great call to check Safari on desktop. I read around about how type=“module” tags are imported with CORS. I added “crossorigin” to the script tag and also added a CORS policy on the S3 bucket.

Not sure which one did the trick but it is working now. Voila !!!

Thank you!!

And @jashkenas you as well - this is an amazing platform and I am absolutely in love with it.
