JavaScript override



  • This is a plugin that I'm proposing to develop.

    It allows for programmatic control of how a browser responds to particular JavaScript files/urls based on arbitrary criteria.

    For example, http://www.gnu.org/philosophy/javascript-trap.html discusses a set of conventions that compressed JavaScript could follow to help identify the "originating entity" of the code, with the intent of making open source code readily available while still providing it in a not-so-human-readable form.

    Of course people bundle copies of JavaScript libraries they use to isolate themselves from incompatible updates and remote server loading too.

    Could the current url scheme used to "fetch" JavaScript code be made to include meta-information such as the ultimate origin / unique-identifier of the item about to be downloaded?

    I think it can, and here's how: establish a convention as to how to interpret specific parts of the url.

    For context, let's say a web site uses jquery, and they have a "compressed" copy on their web site called "jquery-1.6.2.js".

    A well known means of identifying something uniquely is with a UUID, or universal identifier, so just by picking one, say 57898435-a110-4620-8280-37c07357b513, and making it part of the url, you would allow the following parts to specify the "item" (jquery) and the version (1.6.2), as in

    www.some-site.com/a/b/c/57898435-a110-4620-8280-37c07357b513/jquery-1.6.2.js

    That's all that's needed to allow browsers to identify this entity uniquely and to use a local version in preference to the one available on the web server, say with extra debugging, or more limited features.

    One could use such a scheme to avoid having to download the file completely and provide equivalent functionality with a plugin, something I plan to do.

    A fallback would be to include version and origin information in the compressed JavaScript file itself, but in my book that's already too late as there's an element of trust that the files version is the version the file says it is.

    Providing the name and version in the url avoids this.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.