error from jQuery and also from embedded_sagecell

28 views
Skip to first unread message

David Farmer

unread,
Dec 29, 2018, 5:32:26 PM12/29/18
to sage-cell

The PreTeXt project uses sage cells extensively, and also downloads
jQuery from

https://sagecell.sagemath.org/static/jquery.min.js

Recently (the problem was noticed a few days ago) some javascript
on the HTML versions of PreTeXt documents has not been working properly.

For example, on the sample article:

https://pretextbook.org/examples/sample-article/html/

when you scroll down the page, the buttons "Index", "Prev", "Up",
and "Next" should stick at the top of the page. That has stopped
working. Also, on a narrow screen the TOC disappears as it should,
but the hamburger button on the bottom left does not bring it back.

Some clues as to the cause: when the page loads, this error appears
in the console (up-to-date Firefox on a MacBook Pro):

TypeError: e.indexOf is not a function embedded_sagecell.js:2834:82466

When I save the page and load it from a local file, I see a similar
message, but from jquery:

TypeError: e.indexOf is not a function jquery.min.js:2:82466

Note that I plan to change the PreTeXt HTML so that it takes jquery.min.js
from a place I can control.

I realize that embedded_sagecell.js loads its own jQuery, but we need
jQuery for other things (like knowls), so I need to explicitly load it.

My questions:

1. Is it possible to revert the version served at
https://sagecell.sagemath.org/static/jquery.min.js
so that the js used by PreTeXt will work again?

2. When we start serving our own jQuery, do I have to do something
to avoid a conflict between the (older) version of jQuery we load
explicitly, and the (presumably newer) version needed for sage cells?

3. The error message about e.indexOf does not seem to impair the
functioning of sage cells. Could that be a jQuery error which makes
a difference to some javascript, but not to sage cells?

I realize that the example I am providing is far from minimal,
so please let me know if I need to make one. But I think I have
identified the problem because if I comment out the jquery.min.js
and the embedded_sagecell.js coming from sagecell.sagemath.org,
and instead insert an earlier version of jquery.min.js, then
those error messages go away and things work as expected.

Regards,

David

Andrey Novoseltsev

unread,
Dec 29, 2018, 6:15:40 PM12/29/18
to sage-cell
On Saturday, 29 December 2018 15:32:26 UTC-7, David Farmer wrote:
1. Is it possible to revert the version served at
     https://sagecell.sagemath.org/static/jquery.min.js
so that the js used by PreTeXt will work again?

I think it is highly undesirable: jQuery which is bundled in embedded_sagecell.js and is available separately at that location is coming from Jupyter components and so presumably is the one that is needed for them to function. I do see the problems you have described and got a report recently that Firefox 64 on Ubuntu 18.04 does not show the code box on sagecell.sagemath.org. As I have recently upgraded servers to Sage 8.5, this is likely to be related. Reverting back to 8.4 may hide these problems, but won't help with fixing them.


2. When we start serving our own jQuery, do I have to do something
to avoid a conflict between the (older) version of jQuery we load
explicitly, and the (presumably newer) version needed for sage cells?

I have no idea and would be very happy if someone could take a look at it as well and share some thoughts. "Our" jQuery is loaded via require.js here https://github.com/sagemath/sagecell/blob/master/js/cell.js

3.  The error message about e.indexOf does not seem to impair the
functioning of sage cells.  Could that be a jQuery error which makes
a difference to some javascript, but not to sage cells?

Maybe. The Firefox issue I mentioned shows errors related to jquery-touch-punch, which should not matter much, except that overall JS processing may stop.

I realize that the example I am providing is far from minimal,
so please let me know if I need to make one.  But I think I have
identified the problem because if I comment out the jquery.min.js
and the embedded_sagecell.js coming from sagecell.sagemath.org,
and instead insert an earlier version of jquery.min.js, then
those error messages go away and things work as expected.

To clarify: if you comment out embedded_sagecell.js but keep using jquery.min.js from sagecell site the problems are visible?

Thank you!
Andrey

Andrey Novoseltsev

unread,
Dec 29, 2018, 6:47:37 PM12/29/18
to sage-cell
P.S. What happens if you load explicitly your "old" jQuery and only embedded_sagecell.js from sagecell server?

David Farmer

unread,
Dec 29, 2018, 8:12:04 PM12/29/18
to sage-cell

If I keep the jquery from sagecell.sagemath.org and comment out the
embedded_sagecell.js, then the problem persists. (And I see that error
message in console "e.indexOf is not a function".) (Same in Firefox,
Safari, and Chrome.)

If I use a really old version of jQuery (but one that is adequate for
the javascript for PreTeXt and knowl.js), then load embedded_sagecell.js,
the problem persists.

If I load embedded_sagecell.js, and then load an old version of
jQuery, then things work again.

If I load the jQuery from sagecell.sagemath.org, then load
embedded_sagecell.js, then load an old jQuery, then things work
as expected.

However, if I load jQuery from sagecell.sagemath.org, then load
embedded_sagecell.js, then dynamically add and old jQuery at the
end then the problem still occurs. (So that means I don't have an easy
work-around to fix existing pages without rebuilding them.)

I get the e.indexOf error in the console (twice) whenever
embedded_sagecell.js is loaded.


On Sat, 29 Dec 2018, Andrey Novoseltsev wrote:

> P.S. What happens if you load explicitly your "old" jQuery and only embedded_sagecell.js from sagecell server?
>
> --
> You received this message because you are subscribed to the Google Groups "sage-cell" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> sage-cell+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cell/f3ce611f-c5da-4e46-b79d-3bfbb250e2b3%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>

David Farmer

unread,
Dec 29, 2018, 8:24:38 PM12/29/18
to Andrey Novoseltsev, sage-cell

> I have no idea and would be very happy if someone could take a look at it as well and share some thoughts. "Our"
> jQuery is loaded via require.js here https://github.com/sagemath/sagecell/blob/master/js/cell.js
>
> Maybe. The Firefox issue I mentioned shows errors related to jquery-touch-punch, which should not matter much,
> except that overall JS processing may stop.

I agree that reverting makes no sense. But I don't understand how the
jQuery error made it into production. (Implicit in what I just wrote is
that there is an error in jQuery. Please correct me if that is not a
true statement.)

Andrey Novoseltsev

unread,
Dec 30, 2018, 1:46:19 PM12/30/18
to sage-cell
On Saturday, 29 December 2018 18:12:04 UTC-7, David Farmer wrote:

If I keep the jquery from sagecell.sagemath.org and comment out the
embedded_sagecell.js, then the problem persists.  (And I see that error
message in console "e.indexOf is not a function".)  (Same in Firefox,
Safari, and Chrome.)

This suggests that the problem is with PreTeXt, not sagecell. Included jQuery (coming from jupyter/notebook project) got upgraded from 2.2 in Sage 8.4 to 3.3 in Sage 8.5.

If I use a really old version of jQuery (but one that is adequate for
the javascript for PreTeXt and knowl.js), then load embedded_sagecell.js,
the problem persists.

This may indicate some problem with the way embedded_sagecell.js bundles jQuery. My understanding was that require.js will "hide" the internal jQuery version and will not interfere with whatever is loaded outside. But perhaps is has to do some global settings anyway and so overrides the old version included first.

Andrey Novoseltsev

unread,
Dec 30, 2018, 1:59:01 PM12/30/18
to sage-cell
On Saturday, 29 December 2018 18:24:38 UTC-7, David Farmer wrote:
I agree that reverting makes no sense.  But I don't understand how the
jQuery error made it into production.  (Implicit in what I just wrote is
that there is an error in jQuery.  Please correct me if that is not a
true statement.)

Well, it seems that jQuery is not backward compatible between 2.2 and 3.3. Is it supposed to be? (I have no idea.)

Given that PreTeXt pages are likely to be one of our largest "customers", it may make sense to downgrade until the problem is resolved, unless we come up with a solution fast (like a week, before classes start again). Possible ways of downgrading:
1) Replace jquery.min.js served by our servers to 2.2, keeping the rest as is. I have removed loading jquery from instructions a long time ago (it used to be necessary to load jquery and embedded_sagecell as separate scripts), so we kind of don't promise anymore to keep it at all, certainly not at any particular version.
2) Go back to Sage 8.4 without any tweaks to build procedure.
3) What if I just remove that file completely??? Will your pages work if it cannot be loaded, but you add your old version "dynamically"?

In cases 1) and 2) something still has to be done to resolve the problem and make it unnecessary.

Andrey Novoseltsev

unread,
Dec 30, 2018, 2:19:35 PM12/30/18
to sage-cell
On Sunday, 30 December 2018 11:59:01 UTC-7, Andrey Novoseltsev wrote:
Well, it seems that jQuery is not backward compatible between 2.2 and 3.3. Is it supposed to be? (I have no idea.)

Not completely, see https://jquery.com/upgrade-guide/3.0/ with instructions on how to resolve problems.

David Farmer

unread,
Dec 30, 2018, 4:09:22 PM12/30/18
to sage-cell

Yay, Thanks! That was the clue I needed. I never occurred to me that
the new jQuery was not backward compatible.

I have made enough changes to (in the cases I checked) fix the immediate
problem that started this thread. Both the knowls code and the pretext
code needed to be changed.

There are still some error messages, and it looks like the sagecell
code is not completely isolated from the other code, but that is
not a pressing concern at the moment.

I don't think you need to make any changes to the sage cells code
or what you host on sagecell.sagemath.org .

I still plan to have PreTeXt take the jQuery code from somewhere
else, but please leave it up on the sagecell website so that existing
pages will continue to work. If you plan to take it down, let me know
and I'll set up a fallback.

Thanks again!

David
> --
> You received this message because you are subscribed to the Google Groups "sage-cell" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> sage-cell+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cell/93e55a98-2090-4828-877d-11243e7efeda%40googlegroups.com.

Andrey Novoseltsev

unread,
Dec 30, 2018, 4:18:11 PM12/30/18
to sage-cell
Glad to hear that problems are mostly resolved and I didn't even have to do anything!

Thinking further about removing that separate jQuery file - it should not be done since old instructions loaded it and then explicitly used resulting jQuery to make cells. So all those pages will be broken if we no longer host the file and while we do not advertise its existence anymore, it should stay there indefinitely. But, I think, it has to be the same version as the bundled one to reduce surprises.

Reply all
Reply to author
Forward
0 new messages