2 Replies Latest reply on Mar 26, 2008 12:14 PM by Tom N

    Scriptaculous JS files are added twice

    Tom N Newbie

      Scriptaculous has this handy built-in thing where it will automatically load its sub-modules (like effects.js) when you include the base scriptaculous.js. See http://wiki.script.aculo.us/scriptaculous/show/Usage. Unfortunately people don't realize this and add script tags for them anyway; the effect being that the libs are included twice:

      This is the generated portal markup:

      <body id="body">
      <script src="/portal-ajax/dyna/prototype.js" type="text/javascript">
      </script>
      <script src="/portal-ajax/dyna/scriptaculous.js" type="text/javascript">
      </script>
      <script src="http://localhost:8080/portal-ajax/dyna/builder.js" type="text/javascript">
      </script>
      <script src="http://localhost:8080/portal-ajax/dyna/effects.js" type="text/javascript">
      </script>
      <script src="http://localhost:8080/portal-ajax/dyna/dragdrop.js" type="text/javascript">
      </script>
      <script src="http://localhost:8080/portal-ajax/dyna/controls.js" type="text/javascript">
      </script>
      <script src="http://localhost:8080/portal-ajax/dyna/slider.js" type="text/javascript">
      </script>
      <script src="/portal-ajax/dyna/effects.js" type="text/javascript">
      </script>
      <script src="/portal-ajax/dyna/dragdrop.js" type="text/javascript">
      </script>
      <script src="/portal-ajax/dyna/dyna.js" type="text/javascript">
      ....
      


      Note that effects, and dragdrop are there twice -- once with a relative and once with an absolute URL. The absolute URLs are generated on the client when scriptactulous.js is sourced. Also I'm guessing the inclusion of controls, slider and builder are unintentional??

      Just to double check, I looked at FireBug's "net" console and the libs are in fact being downloaded twice by the client.

      The easiest solution would be to utilize the built-in loading like so:
      <script src="scriptaculous.js?load=effects,dragdrop" type="text/javascript"></script>
      

      And then do not explicitly add <script.. tags for effects and dragdrop.

      Environment: JBoss Portal 2.6.4-GA on JBoss AS 4.2.2.GA

      Should I file a bug report?