In-Portal Issue Tracker - In-Portal CMS
Viewing Issue Advanced Details
457 [In-Portal CMS] Front End feature request always 2009-12-16 14:45 2010-07-22 15:06
Dmitry  
!COMMUNITY  
normal  
closed 5.0.1  
fixed  
 
none 5.1.0-B1  
Google Groups http://groups.google.com/group/in-portal-dev/browse_thread/thread/d81f3bf4d0f0bd38
Ability to automatically compress JS and CSS files on request
0
0000457: Automatic CSS / JS Compression
The elegant and simple implementation (doesn't exist yet) of solving problems with large javascript, css files being sent on every page load.

Instead of
<script type="text/javascript"
src="<inp2:m_TemplatesBase/>js/script.js"></script>

we should use

<script type="text/javascript" src="<inp2:m_Script
file="js/script.js"/>"></script>


Tag Script would:

1. get compressed version of given file based on current theme (compressed
versions could be stored under "/system/cache")

2. if given file was changed after compressed file was created, then create
compressed file with file modification time in it's name and return url to
compressed file

3. if given file wasn't changed after compressed file was created, then
return url to compressed file


There would not be any additional calls to index.php to load every
compressed javascript, because of tag implementation is being used. What
ever compression is made or not could be determined by new configuration
variable. Compression could be turned off automatically, when debug mode is
turned on for example. What compressor to use would be determined based on
given file extension. What compressor engine to use will be determined in
later development stages of this feature (command-line, php, java etc.).


NOTE:

We should be able to process multiple JS files (and probably CSS) in a single minimized version.

Let's say I want something like this <script type="text/javascript"
src="<inp2:m_Script file="js/script.js|js/another_jq.js"/>"></script>
I did see it a few times like this - can't remember the software /
website, but will find this and put examples here.
Need to find good Compress methods for both CSS and JS files.

Here are some samples:

- http://code.google.com/p/jsmin-php/
- http://davidwalsh.name/css-compression-php
related to 0000704closed  (5.1.0)alex Improvements to "E-mail Template" editing 
parent of 0000761closed  (5.1.0)alex Bug related to SSL in JS/CSS compress feature 
parent of 0001167closed  (5.2.0)alex Improvements in Compressed CSS/JS File Naming 
has duplicate 0000040closed  (Icebox)Dmitry Issues with JavaScript and CSS Caching 
related to 0000752closed  (5.1.0)alex Uploader javascript is not compressed 
related to 0001177closed  (5.2.0)alex Debug version of CSS/JS files (decompressed) loaded even after Debug is Disabled via Cookies 
patch js_css_compress_core.patch (44,612) 2010-05-04 14:05
http://tracker.in-portal.org/file_download.php?file_id=516&type=bug
patch js_css_compress_modules.patch (1,554) 2010-05-04 14:05
http://tracker.in-portal.org/file_download.php?file_id=517&type=bug
patch js_css_compress_themes.patch (41,426) 2010-05-04 14:06
http://tracker.in-portal.org/file_download.php?file_id=518&type=bug
patch disabled_compression_during_debugging.patch (449) 2010-05-12 04:38
http://tracker.in-portal.org/file_download.php?file_id=534&type=bug
patch infinite_compression_fix.patch (744) 2010-05-15 07:36
http://tracker.in-portal.org/file_download.php?file_id=547&type=bug
patch still_using_old_compressed_code_after_upgrade.patch (410) 2010-05-18 08:02
http://tracker.in-portal.org/file_download.php?file_id=557&type=bug
Issue History
2011-12-08 03:46 alex Relationship added related to 0001177
2011-12-02 04:56 alex Relationship replaced has duplicate 0000040
2011-11-13 17:08 Dmitry Relationship added parent of 0001167
2010-08-31 14:23 alex Relationship added related to 0000040
2010-07-22 15:06 alex Note Added: 0002519
2010-07-22 15:06 alex Status resolved => closed
2010-06-08 03:30 alex Relationship added parent of 0000761
2010-05-31 14:52 Dmitry Note Added: 0002349
2010-05-31 14:52 Dmitry Status reviewed and tested => resolved
2010-05-31 14:52 Dmitry Resolution reopened => fixed
2010-05-31 14:52 Dmitry Note Added: 0002348
2010-05-31 14:52 Dmitry Status needs testing => reviewed and tested
2010-05-31 04:56 alex Note Added: 0002346
2010-05-31 04:56 alex Assigned To alex => !COMMUNITY
2010-05-31 04:56 alex Status needs feedback => needs testing
2010-05-30 19:37 Dmitry Note Added: 0002340
2010-05-30 19:37 Dmitry Status resolved => needs feedback
2010-05-30 19:37 Dmitry Resolution fixed => reopened
2010-05-29 16:38 alex Relationship added related to 0000752
2010-05-19 02:45 alex Changeset attached 5.1.x r13585
2010-05-19 02:45 alex Note Added: 0002250
2010-05-19 02:45 alex Status reviewed and tested => resolved
2010-05-19 02:45 alex Resolution reopened => fixed
2010-05-18 20:24 Dmitry Note Added: 0002238
2010-05-18 20:24 Dmitry Assigned To !COMMUNITY => alex
2010-05-18 20:24 Dmitry Status needs testing => reviewed and tested
2010-05-18 08:03 alex Relationship added related to 0000704
2010-05-18 08:03 alex Note Added: 0002228
2010-05-18 08:03 alex Status needs feedback => needs testing
2010-05-18 08:02 alex File Added: still_using_old_compressed_code_after_upgrade.patch
2010-05-18 08:02 alex Assigned To alex => !COMMUNITY
2010-05-18 08:02 alex Note Added: 0002227
2010-05-18 08:02 alex Status resolved => needs feedback
2010-05-18 08:02 alex Resolution fixed => reopened
2010-05-16 22:05 Dmitry Note Added: 0002217
2010-05-15 07:39 alex Note Added: 0002210
2010-05-15 07:39 alex Changeset attached 5.1.x r13564
2010-05-15 07:36 alex File Added: infinite_compression_fix.patch
2010-05-12 04:40 alex Changeset attached 5.1.x r13560
2010-05-12 04:39 alex Note Added: 0002196
2010-05-12 04:38 alex File Added: disabled_compression_during_debugging.patch
2010-05-05 02:06 alex Note Added: 0002057
2010-05-05 02:06 alex Status reviewed and tested => resolved
2010-05-05 02:06 alex Fixed in Version => 5.1.0-B1
2010-05-05 02:06 alex Resolution open => fixed
2010-05-05 02:06 alex Changeset attached 5.1.x r13487
2010-05-05 01:48 alex Changeset attached 5.1.x r13486
2010-05-05 01:43 alex Changeset attached 5.1.x r13485
2010-05-05 01:40 alex Changeset attached 1.1.x r13484
2010-05-05 01:38 alex Changeset attached 1.1.x r13483
2010-05-05 01:37 alex Changeset attached 5.1.x r13482
2010-05-05 01:37 alex Note Added: 0002056
2010-05-05 01:34 alex Changeset attached 1.1.x r13481
2010-05-04 20:32 Dmitry Note Added: 0002055
2010-05-04 20:32 Dmitry Assigned To !COMMUNITY => alex
2010-05-04 20:32 Dmitry Status needs testing => reviewed and tested
2010-05-04 14:17 alex Note Added: 0002053
2010-05-04 14:17 alex Assigned To alex => !COMMUNITY
2010-05-04 14:17 alex Developer => alex
2010-05-04 14:17 alex Status needs work => needs testing
2010-05-04 14:06 alex File Added: js_css_compress_themes.patch
2010-05-04 14:05 alex File Added: js_css_compress_modules.patch
2010-05-04 14:05 alex File Added: js_css_compress_core.patch
2010-04-28 11:45 Dmitry Change Log Message => Ability to automatically compress JS and CSS files on request
2010-04-28 11:45 Dmitry Status active => needs work
2010-04-12 16:52 Dmitry Status needs work => active
2010-04-08 23:57 Dmitry Assigned To => alex
2010-04-08 23:57 Dmitry Status active => needs work
2010-04-08 23:57 Dmitry Description Updated bug_revision_view_page.php?rev_id=428#r428
2010-04-08 23:56 Dmitry Target Version Icebox => 5.1.0
2009-12-16 15:03 Dmitry Target Version => Icebox
2009-12-16 14:45 Dmitry New Issue
2009-12-16 14:45 Dmitry Reference => Google Groups http://groups.google.com/group/in-portal-dev/browse_thread/thread/d81f3bf4d0f0bd38

Notes
(0002053)
alex   
2010-05-04 14:17   
Tag "m_Compress" added. Supported usages are (you can also use "css", where I use "js" in examples):

1. <inp2:m_Compress files='path/to/file_a.js|path/to/file_b.js'/>

Will use relative paths to css/js files or complete urls (from any js/css from the site) as input and:
- will combine contents of all listed files into once single file
- minify that file
- return full url to that file

2. <inp2:m_Compress files='path/to/file_a.js|path/to/file_b.js' to="var_name"/>

Will put all listed files to variable given in "to" parameter for later usage (like queuing)

3. <inp2:m_Compress from="var_name"/>

Will act like "1." except, that actual files will be retrieved from variable given in "from" parameter and not from "files" parameter as usual.

4. <inp2:m_Compress type="js">
sample js code here to replace with minified version
</inp2:m_Compress>

Will minify code inside "m_Compress" tag and replace original code.
(0002055)
Dmitry   
2010-05-04 20:32   
Tested good, please commit!
(0002056)
alex   
2010-05-05 01:37   
Since all "CSS" files are compressed into same path under /system/cache folder, then relative paths to images inside CSS files won't work.

As work around I've introduced "@templates_base@" string, that can be placed into CSS file being compressed. During compression it will be replaced to full url to theme (without trailing slash).
(0002057)
alex   
2010-05-05 02:06   
Fix committed to 5.1.x branch. Commit Message:

Fixes 0000457: Automatic CSS / JS Compression
(0002196)
alex   
2010-05-12 04:39   
Patch "disabled_compression_during_debugging.patch" (already commited) disables compression even, when we are debugging using Zend Studio.
(0002210)
alex   
2010-05-15 07:39   
Patch "infinite_compression_fix.patch" (already commited) fixes case, that files got re-compressed again and again when I switch debug mode on and off (debug file generation time was overwriting non-debug file generation time and so on).
(0002217)
Dmitry   
2010-05-16 22:05   
Tested good.
(0002227)
alex   
2010-05-18 08:02   
All compressed code is not updated during upgrade to new version (e.g. from 5.1.0 to 5.1.1), since theme cache is not rebuild on upgrade.
(0002228)
alex   
2010-05-18 08:03   
Patch "still_using_old_compressed_code_after_upgrade.patch" fixes compressed file cache not being reset during upgrade.
(0002238)
Dmitry   
2010-05-18 20:24   
New patch tested good, please commit.
(0002250)
alex   
2010-05-19 02:45   
Fix committed to 5.1.x branch. Commit Message:

Fixes 0000457: Automatic CSS / JS Compression
(0002340)
Dmitry   
2010-05-30 19:37   
UPDATE:

There are some JS errors when compression is ON or OFF in IE 8 with compatibility mode On or IE7. All details posted here.

Below are the error list provided by IE (I am trying to go to Polls grid after login)

=============
Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB6.4; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)
Timestamp: Mon, 31 May 2010 00:25:55 UTC


Message: Expected identifier, string or number
Line: 1079
Char: 235
Code: 0
URI: http://www.jurmala.com/SVN/5.1.x/system/cache/c_1159502181_1275265484.js


Message: 'TB' is undefined
Line: 31
Char: 1
Code: 0
URI: http://www.jurmala.com/SVN/5.1.x/admin/index.php?env=-tree:m0--1--s-


Message: Object expected
Line: 13
Char: 2
Code: 0
URI: http://www.jurmala.com/SVN/5.1.x/core/admin_templates/js/tree.js


Message: Object expected
Line: 301
Char: 2
Code: 0
URI: http://www.jurmala.com/SVN/5.1.x/core/admin_templates/js/tree.js


Message: 'Application' is undefined
Line: 359
Char: 3
Code: 0
URI: http://www.jurmala.com/SVN/5.1.x/admin/index.php?env=-tree:m0--1--s-


Message: Expected identifier, string or number
Line: 1079
Char: 235
Code: 0
URI: http://www.jurmala.com/SVN/5.1.x/system/cache/c_1159502181_1275265484.js


Message: Expected identifier, string or number
Line: 1079
Char: 235
Code: 0
URI: http://www.jurmala.com/SVN/5.1.x/system/cache/c_1159502181_1275265484.js


Message: 'TB' is undefined
Line: 30
Char: 1
Code: 0
URI: http://www.jurmala.com/SVN/5.1.x/admin/index.php?env=-in-bulletin/polls/poll_list:m0--1--s-


Message: 'TB' is undefined
Line: 31
Char: 1
Code: 0
URI: http://www.jurmala.com/SVN/5.1.x/admin/index.php?env=-head:m0--1--s-


Message: Object expected
Line: 217
Char: 3
Code: 0
URI: http://www.jurmala.com/SVN/5.1.x/admin/index.php?env=-in-bulletin/polls/poll_list:m0--1--s-


Message: 'AjaxPopupManager' is undefined
Line: 188
Char: 2
Code: 0
URI: http://www.jurmala.com/SVN/5.1.x/admin/index.php?env=-head:m0--1--s-


Message: 'ToolBar' is undefined
Line: 233
Char: 7
Code: 0
URI: http://www.jurmala.com/SVN/5.1.x/admin/index.php?env=-in-bulletin/polls/poll_list:m0--1--s-


Message: 'Application' is undefined
Line: 286
Char: 3
Code: 0
URI: http://www.jurmala.com/SVN/5.1.x/admin/index.php?env=-head:m0--1--s-


Message: 'ToolBar' is undefined
Line: 305
Char: 8
Code: 0
URI: http://www.jurmala.com/SVN/5.1.x/admin/index.php?env=-in-bulletin/polls/poll_list:m0--1--s-


Message: 'GridScrollers' is undefined
Line: 362
Char: 3
Code: 0
URI: http://www.jurmala.com/SVN/5.1.x/admin/index.php?env=-in-bulletin/polls/poll_list:m0--1--s-


Message: 'Grids' is undefined
Line: 525
Char: 2
Code: 0
URI: http://www.jurmala.com/SVN/5.1.x/admin/index.php?env=-in-bulletin/polls/poll_list:m0--1--s-


Message: 'Application' is undefined
Line: 548
Char: 3
Code: 0
URI: http://www.jurmala.com/SVN/5.1.x/admin/index.php?env=-in-bulletin/polls/poll_list:m0--1--s-
===============
(0002346)
alex   
2010-05-31 04:56   
There is no problem with compression at all. Since now all JS is merged into one file, then you will see errors from all js files on every page, even if it's not used there.

In this case, problem was in "form_controls.js" file with trailing comma in object declaration. Problem was moved here 0000757. Please test this task and I will make it resolved.
(0002348)
Dmitry   
2010-05-31 14:52   
Completed.
(0002349)
Dmitry   
2010-05-31 14:52   
Reopened by mistaken.
(0002519)
alex   
2010-07-22 15:06   
Closing, since 5.1.0 release has been released.