Hide js files

Alexandr Kosarev - July 26, 2008 - 09:52

I see for way to hide js files.
For example if I have

<script type="text/javascript" src="/misc/jquery.js"></script>

I want to have
<script type="text/javascript" src="/somethingrandom.js"></script>

something like alias for js files

at moment I did this in my theme, just to parse $scripts, copy files to random names and replays original paths.

can I do this somehow in module without affect theme?

As I said my solution is

Alexandr Kosarev - March 27, 2009 - 20:20

As I said my solution is theme based and look like this:

        preg_match_all('/src="(.*)"/', $scripts, $matches);
        list( ,$matches) = $matches;
        foreach($matches as $js_file) {
          $md5_js = '/files/'.md5($js_file).'.js';
          $scripts = str_replace($js_file, $base_url.$md5_js, $scripts);
          if (!is_file(getcwd().$md5_js)) {
            copy(getcwd().$js_file),  getcwd().$md5_js);
          }
        }

it is theme hack but do work and js files have md5 hashes instead real names. And in my case handled with lighttpd as static content in files directory.

=-=

VeryMisunderstood - March 27, 2009 - 20:32

I'd think you can also use:

on drupal 6.x turn on js aggregation in administer -> performance
on drupal 5.x investigate the contrib js aggregation.module

I can not migrate from Drupal

Alexandr Kosarev - March 28, 2009 - 00:06

I can not migrate from Drupal 5 to 6 at this time.

I already know about Javascript Aggregator, but it have several unclosed bug reports, which stop me to use it.

 
 

Drupal is a registered trademark of Dries Buytaert.