The assets in In-Portal are managed by "<inp2:m_Compress .../>
" tag (see
Jira Legacy |
---|
server | System Jira |
---|
serverId | 513b375f-8291-3313-9d9f-704c39b1f915 |
---|
key | INP-382 |
---|
|
). It works like this:
- create some assets "*.js" or ".css" files
- instead of referencing assets directly specify their relative path in "m_Compress" tag (example below)
- internally a combined minified file of all specified assets is created and it's url is used in HTML
Code Block |
---|
|
<script type="text/javascript" src="<inp2:m_Compress files='js/script.js|js/calendar/calendar-setup.js'/>"></script>
<link rel="stylesheet" href="<inp2:m_Compress files='js/jquery/thickbox/thickbox.css|js/calendar/calendar-blue.css'/>" type="text/css" media="screen"/> |
Asset building process differs radically for website visitors and developers:
...
There are several issues, that can happen:
...
If compression error happens, then empty combined asset file would be
...
created without indication about the fact, that compression error happened.
When the need for asset management araised in 2010 there was no alternatives on the market (the https://github.com/kriswallsmith/assetic was developed in 2011) and we had to write something ourselves. This unfortunately forced us to copy/paste specific (latest at the time) versions of "JsMin" and "CssMin" into In-Portal. As a result we're not receiving any updates/fixes from these libraries as well.
Fixtures
...
Code Block |
---|
language | css |
---|
title | Non-Minified File |
---|
linenumbers | true |
---|
|
@media screen and (min-width: 480px) and (max-width: 639px) {
body {
background: #000 url(/themes/advanced/img/header-bg.png) no-repeat top left;
}
}
@media screen and (max-width: 640px) {
body {
background: #000 url(/themes/advanced/img/header-bg.png) no-repeat top left;
}
} |
...
Code Block |
---|
language | css |
---|
title | Compressed File Using YUICompressor 2.4.2 |
---|
linenumbers | true |
---|
|
@media screen and(min-width:480px) and(max-width:639px){body{background:#000 url(/themes/advanced/img/header-bg.png) no-repeat top left;}}@media screen and(max-width:640px){body{background:#000 url(/themes/advanced/img/header-bg.png) no-repeat top left;}} |
...
Code Block |
---|
language | css |
---|
title | Compressed File Using YUICompressor 2.4.8 |
---|
linenumbers | true |
---|
|
@media screen and (min-width:480px) and (max-width:639px){body{background:#000 url(/themes/advanced/img/header-bg.png) no-repeat top left;}}@media screen and (max-width:640px){body{background:#000 url(/themes/advanced/img/header-bg.png) no-repeat top left;}} |
...
Code Block |
---|
language | css |
---|
title | Minified using PHPMin |
---|
linenumbers | true |
---|
|
@media screen and (min-width: 480px) and (max-width: 639px){body{background:#000 url(/themes/advanced/img/header-bg.png) no-repeat top left}}@media screen and (max-width: 640px){body{background:#000 url(/themes/advanced/img/header-bg.png) no-repeat top left}} |
Solution
- use https://github.com/kriswallsmith/assetic library for asset file creation (internals of "m_Compress" tag)
- use JsMin and CssMin from Composer
- deprecate "JsMinifyHelper" and "CssMinifyHelper" classes in favor of "MinifyHelper::compressString" method
- store compiled assets in "/system/cache/assets/" folder instead of "/system/cache/" folderupgrade used YUICompressor version from 2.4.2 to 2.4.8
Related Discussions
Related Tasks
Jira Legacy |
---|
server | System Jira |
---|
serverId | 513b375f-8291-3313-9d9f-704c39b1f915 |
---|
key | INP-1687 |
---|
|