code: private String getContent(TreeLogger logger, String path, String src)
        throws UnableToCompleteException {
      HttpURLConnection connection = null;
      InputStream in = null;
      try {
        if (!src.matches("(?i)https?://.*")) {
          String file = path + "/" + src;
          in = this.getClass().getClassLoader().getResourceAsStream(file);
          if (in == null) {
            // If we didn't find the resource relative to the package, assume it is absolute.
            file = src;
            in = this.getClass().getClassLoader().getResourceAsStream(file); 
          }
          if (in != null) {
            logger.log(TreeLogger.INFO, getClass().getSimpleName()
                + " - importing external javascript: " + file);
          } else {
            logger.log(TreeLogger.ERROR, "Unable to read javascript file: " + file);
          }
        } else {
          logger.log(TreeLogger.INFO, getClass().getSimpleName()
              + " - downloading external javascript: " + src);
          URL url = new URL(src);
          connection = (HttpURLConnection) url.openConnection();
          connection.setRequestProperty("Accept-Encoding", "gzip, deflate");
          connection.setRequestProperty("Host", url.getHost());
          connection.setConnectTimeout(3000);
          connection.setReadTimeout(3000);
  
          int status = connection.getResponseCode();
          if (status != HttpURLConnection.HTTP_OK) {
            logger.log(TreeLogger.ERROR, "Server Error: " + status + " "
                + connection.getResponseMessage());
            throw new UnableToCompleteException();
          }
  
          String encoding = connection.getContentEncoding();
          in = connection.getInputStream();
          if ("gzip".equalsIgnoreCase(encoding)) {
            in = new GZIPInputStream(in);
          } else if ("deflate".equalsIgnoreCase(encoding)) {
            in = new InflaterInputStream(in);
          }
        }
  
        return inputStreamToString(in);
      } catch (IOException e) {
        logger.log(TreeLogger.ERROR, "Error: " + e.getMessage());
        throw new UnableToCompleteException();
      } finally {
        if (connection != null) {
          connection.disconnect();
        }
      }
    }
docs: Get the content of a javascript source. It supports remote sources hosted in CDN's.