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

NON local javascript files make developing JS impossible offline #14

Open
MareoRaft opened this issue May 17, 2016 · 2 comments
Open

NON local javascript files make developing JS impossible offline #14

MareoRaft opened this issue May 17, 2016 · 2 comments

Comments

@MareoRaft
Copy link
Owner

Please configure requirejs to FALLBACK to a local version if an online version fails.

Or simpler, just make all JS libraries local.

@MareoRaft
Copy link
Owner Author

I made a local version of all the JS files except for Mathjax. That is, there is now a local version of mathjax but our website doesn't use it. For some reason, using the local version causes a JS error.

For everything else, you can see in config.js that we are now using a local minified copy:

    paths: { // other paths we want to access
        jquery: "jquery-min", //"http://code.jquery.com/jquery-1.11.2.min",
        underscore: "underscore-min", //"https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min",
        d3: "d3-for-development", // if we add patches separately, then we can just use https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min
        katex: "katex-min", //"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min", // or 0.2.0
        mathjax: "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML&delayStartupUntil=configured", //"mathjax-min.js?config=TeX-AMS_HTML&delayStartupUntil=configured",
        // marked: "https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.2/marked.min", // disabled for consistent development
        chosen: "chosen-min", //"https://cdnjs.cloudflare.com/ajax/libs/chosen/1.4.2/chosen.jquery.min",
        jsnetworkx: "jsnetworkx-min", //"https://raw.githubusercontent.com/fkling/JSNetworkX/v0.3.4/jsnetworkx", //actually we maybe should download this
        main: "../main" },

The next step is I'll see if requireJS supports a FALLBACK method, so the browser can try both.

@MareoRaft
Copy link
Owner Author

MareoRaft commented May 20, 2016

I have verified that using arrays allows requirejs to try a backup if a certain resource fails. So now the code is

    paths: { // other paths we want to access
        // keep in mind that the local and remote URLS are not necessarily the same version of the library.  but no issues so far.
        jquery: ["jquery-min", "http://code.jquery.com/jquery-1.11.2.min"],
        underscore: ["underscore-min", "https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min"],
        d3: "d3-for-development", // if we add patches separately, then we can just use https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min
        katex: ["katex-min", "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min"], // or 0.2.0
        mathjax: "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML&delayStartupUntil=configured", //"mathjax-min.js?config=TeX-AMS_HTML&delayStartupUntil=configured",
        marked: ["marked", "https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.2/marked.min"],
        chosen: ["chosen-min", "https://cdnjs.cloudflare.com/ajax/libs/chosen/1.4.2/chosen.jquery.min"],
        jsnetworkx: ["jsnetworkx-min", "https://raw.githubusercontent.com/fkling/JSNetworkX/v0.3.4/jsnetworkx"],
        main: "../main"
    },

But I still can't close this issue because of Mathjax. Also, it's possible that requirejs or some other JS library calls upon an external resource, but we won't be able to verify that until we fix the Mathjax issue.

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

No branches or pull requests

1 participant