Next: , Previous: , Up: Top   [Contents]

5 JavaScript Detection

In practice, the JavaScript code in your page may be found trivial by LibreJS if, as a whole:

However, in some instances, you may be required by LibreJS to add a stylized comment to JavaScript code that may be otherwise trivial.

When an external file defines a function, it becomes available to all other external scripts. That is the case if another script defines a function that makes AJAX calls, when an external script loads other scripts dynamically (which in turn could also make AJAX calls, …), or when a script is written with constructs that may do any of these.

For instance, if your page contains the following:

<script src="jquery.js"></script>

While $.doSomething(); may seem trivial, you will nevertheless have to add a stylized license comment on your main HTML page because the external script (in this case jQuery) has been found to define methods that make AJAX calls. $.doSomething() might make an AJAX call, and LibreJS does not check for that. The rule of thumb is that when you use a library or code that handles AJAX, JSON, JSONP, the loading of scripts dynamically, you should have license mentions for all your JavaScript files and for your main page regardless. In practice this is a case that happens very often with code that uses libraries.

In practice also, the JavaScript code in an external file (an external .js file loaded on your page) may be found trivial if it does not define functions/methods.

And in the same manner it will be considered nontrivial if AJAX calls, dynamic script loading, or non-obvious dynamic JavaScript constructs are used in another script.

If your JavaScript code makes AJAX requests, it’s important to get an accurate Content-Type in the response from the server. For example, if you’re using JSON, set it to application/json. This is because LibreJS alters the content of text/html responses.

Next: , Previous: , Up: Top   [Contents]