Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent approach for HTML/JS output on nbviewer #5084

Closed
ellisonbg opened this issue Feb 9, 2014 · 5 comments
Closed

Consistent approach for HTML/JS output on nbviewer #5084

ellisonbg opened this issue Feb 9, 2014 · 5 comments
Assignees
Milestone

Comments

@ellisonbg
Copy link
Member

This is probably more to do with nbviewer than IPython, but I wanted to start the discussion here. Pinging @wrobstory @jakevdp @rgbkrk as well.

The issue is that nbviewer doesn't provide the same runtime environment as the live notebook. There are a couple of differences:

  • JS output is not run at all. This forces people to put JS code in <script> tags to get it to work with nbviewer.
  • jQuery is loaded at the bottom of the page, so any JS code that does get run in script tags doesn't have jQuery. This means that proejcts like mpld3 have to do wonky things like this because $.getScript doesn't exist:

https://github.com/jakevdp/mpld3/blob/master/mpld3/_objects.py#L192

  • require.js is not on the page. Libraries such as d3 exhibit different initialization logic if require is defined. Both vincent and mpld3 have to have special cases to cover nbviewer right now as it doesn't have require.js on the page.

Here is a notebook on nbviewer that shows these issues:

http://nbviewer.ipython.org/gist/ellisonbg/8906675

Here is my proposal for 2.0:

  • In the nbviewer template add require.js at the top of the page (above the body).
  • Move jQuery to the top of the page (above the body).
  • Enable the display of JS output.

This should unify the live notebook and nbviewer for 2.0 at a reasonable level.

@ellisonbg ellisonbg added this to the 2.0 milestone Feb 9, 2014
@rgbkrk
Copy link
Member

rgbkrk commented Feb 9, 2014

Sounds good to me, but I'm no javascript ninja (hopefully I'll get to work on that soon).

We probably need to do some javascript cleanup anyway. I noticed this 404 on all of our rendered pages while I was investigating network timings for @CamDavidsonPilon's notebook:

screen shot 2014-02-09 at 3 33 52 pm

Then found out this is a source map file that jQuery looks for when in developer tools.

@rgbkrk
Copy link
Member

rgbkrk commented Feb 24, 2014

This is definitely the next thing that needs to be tackled. Thanks again @ellisonbg.

@jakevdp
Copy link
Contributor

jakevdp commented Feb 24, 2014

I'd add one more thing to this: it would also be nice if nbconvert html output could be set up to make this convenient as well. Currently when I blog with the IPython notebook using Javascript tricks, I have to worry about three different platforms: IPython notebook itself, nbviewer, and nbconvert html.

@damianavila
Copy link
Member

Probably we can put this things it in the head of nbconvert html output and then the issue will be solved in nbviewer too, because it is using nbconvert underlying...

@jdfreder
Copy link
Member

I think #5232 and jupyter/nbviewer#211 together close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants