Login / Logout



Advertisement

CssJsCompress X

CssJsCompress is a Joomla extension that can combine external javascript files as one compressed file to improve the speed of your Joomla site.

I had have a problem with the Joomla extension because CssJsCompress is not aware of the page having javascript written directly with a framework (e.g MooTools).

The situation I encountered:

<head>
  (Omitting)
  <title>Page Title</title>
  (Omitting)
  <script type="text/javascript">

    // In this example the following code is expecting Mootools to be loaded by now.
    // But CssJsCompress generates SCRIPT tag before HEAD tag closing.
    // Therefore, this code will be error.

    window.addEvent('domready', function() { // Mootools is not loaded, yet

      // Some javascript logic with Mootools

    });

    // Mootools is loaded in the next SCRIPT tag as a part of the combined file
    // made by CssJsCompress. Which is too late for the code above.
  </script>
  <script type="text/javascript" src="/blah/CssJsCompress/js.php?js=blahblah.js.gz"></script>
</head>


So the other day I customised the extension as it loads the combined file after TITLE tag instead. And tadaaaa, this website works with the extension now
:)

What CssJsCompress X does:

<head>
  (Omitting)
  <title>Page Title</title>
  <script type="text/javascript" src="/blah/CssJsCompress/js.php?js=blahblah.js.gz"></script>
  (Omitting)
  <script type="text/javascript">

    // Mootools is loaded before the sample code

    window.addEvent('domready', function() {

      // Some javascript logic with Mootools

    });

  </script>
</head>

 

download

Download CssJsCompress X

Please register or login to download this file

About the Author

Hiro Nozu

Hiro Nozu is a web developer who specializes in building CMS websites with Joomla. He has been in the field for over 10 years, and has been loving every minute of it. Check out some of his past work. He developed the extension Easy Search after the 3 months of involvement in the CMS at iFactory.

Comments (3)

  • Jake Knight
    Jake Knight
    29 November 2010 at 13:07 |

    This plugin solved a major issue with the previous version that nearly destroyed major functionality of my site. I could not find anything in the forums about my problem.

    The issue was that CSSJSCompress was causing all of my modal popup windows to fail and load as separate pages. This was occurring in both K2 and JEvents edit and details windows.

    I don't understand the language about loading the Javascript below the title, but for whatever reason it worked. I've been dealing with this for weeks.

  • Jake Knight
    Jake Knight
    30 November 2010 at 08:18 |

    Same commenter as above:

    The updated plgin crashed several features of JEvents on my site. It caused white pages, which according to JEvents is caused by memory issues (Mine were set to 32m). I've since excluded JEvents and now everything works well again.

    • Hiro
      Hiro
      18 December 2010 at 01:09 |

      Thank you for the report. Let me know if something is up again.

Leave a comment

Please login to leave a comment. Optional login below.