Topic: Can themeUrl be null/ not loaded?

Hello,

I am using Juicebox embedded on a page, and would like to combine the theme.css file into another CSS file that's loaded on the page, reducing requests. However, there doesn't appear to be a way to disable the 'themeUrl' parameter, to have it NOT try to load a CSS file.

Is there a way to disable Juicebox from trying to load the theme.css file completely, and letting it simply continue without loading a file?

I could use http://0.0.0.0 for the themeUrl, as this sort of does avoid a request (takes ~2μs in the network tab, vs ~300ms for a invalid path, ~1s for 127.0.0.1), but would rather not have a 404 show up in the network/ console tabs.

Thanks,
Tony

Re: Can themeUrl be null/ not loaded?

Juicebox will always try to load a themeUrl file and there is no way to prevent this.
If no themeUrl entry is specified in the gallery's embedding code, then Juicebox will look for (and try to load) the 'theme.css' file inside the gallery's 'jbcore/classic/' folder.
If you really want to add the contents of the 'theme.css' file to another CSS file and prevent an error 404 from occurring, then you could load a blank/empty 'theme.css' file.

3 (edited by dsTony 2018-12-07 05:29:50)

Re: Can themeUrl be null/ not loaded?

Thanks for the reply Steven, off the top of your head, there's nothing in the JS that I could change so that if themeUrl == "false" for example, it doesn't try to load it?

I tried to follow the code, but it was a bit too much for me regarding how the themeUrl is processed/ loaded.

I was able to previously make a change that allowed me to inline the XML file that 'configUrl' looks for, and if it's the start of the XML file, simple read it from there, reducing a request to get the XML file (http://prntscr.com/lrt64k).

I tried looking at the

D.theme = J(D.themeurl, D.theme);

line, figured it was somewhere around there, but I don't really see where the stylesheet is being loaded.

Using http://0.0.0.0 from what I've seen would (to me, probably) be better than trying to load an empty file, as that's still an extra get request, which takes time and can stall other things.

4 (edited by dsTony 2018-12-07 05:44:15)

Re: Can themeUrl be null/ not loaded?

Hello Steven,

I think that I found what I was looking for, around line 14612:

var bL = function (a) {
//return;
if (a == "false") return;

With this, I don't see any 404's or anything, and I don't see any stylesheets trying to be loaded on the page, so I believe that this is what I was looking for. Using a == "false" means that I can change themeUrl to "false", and be able to load the juicebox.css file bundled with another combined stylesheet.

I'm using a string "false" as I'm generating this in PHP which doesn't translate booleans too well.

Thanks,
Tony

Re: Can themeUrl be null/ not loaded?

Just to let you know, modifying the source code is not supported so I hope you understand why I could not recommend or suggest such modifications.
Please see this FAQ:

Does Juicebox-Pro include the source code?
No. The Juicebox source code is obsfuscated. Modifying the source code is not supported. JavaScript developers can use the Juicebox API to modify and extend Juicebox functionality.

That said, I hope you are able to achieve what you are looking to do.