The trick in this recipe is to check for the existence of a specific thing that library defines. For instance, checking if the jquery object already exists in the context of the page and do something only when it does not exist. So, in the next code snippet, which could be included in a facelets template of a JSF application, one could specify that need based on the existence of the jQuery object:
// using jquery that is being used by JSF window.jQuery || document.write("\x3C/script>")
This recipe is not a wonderful one but has proved to be useful before for me. Maybe it may be useful for someone else too. Hope you enjoy it!