1

I have an html page (generic). This page may belong to any user. And I have a custom JavaScript that renders a widget at the bottom of the page. This script depends on 4 other JS scripts. And I need to provide a single and short script to users which they can include on their pages and see the widget. But how to do that properly? I tried to use jersey endpoint, but in this case I will have to deal with JS files in Java code. And I will have to sync scripts on page and scripts in code. In other words:

A page:

<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/prefixfree.min.js"></script>
<script src="js/jquery.textarea_autosize.min.js"></script>
<script src="js/custom.js"></script>
<script src="js/chat_loader.js"></script>

What user should see:

<script type="text/javascript">
  var widget_id=<ID>;

  //somehow load those 6 files above in compressed format. 

</script>

How to do that properly? The main issue is I don't want to use/compress those scripts in Java code and html pages the same time. May be it's better to load them one by one in one big client's script? My app is a java app, gradle+Jersey+Java8+jquery

avalon
  • 2,231
  • 3
  • 24
  • 49
  • 1
    Just concatenate the files using a build tool like webpack or gulp or grunt. – Moose Jan 03 '17 at 22:29
  • Possible duplicate of [How do I include a JavaScript file in another JavaScript file?](http://stackoverflow.com/questions/950087/how-do-i-include-a-javascript-file-in-another-javascript-file) – Heretic Monkey Jan 03 '17 at 22:56

0 Answers0