{"id":15532,"date":"2018-04-05T00:34:12","date_gmt":"2018-04-05T07:34:12","guid":{"rendered":"https:\/\/www.exoplatform.com\/blog\/?p=15532"},"modified":"2023-07-06T00:35:28","modified_gmt":"2023-07-05T22:35:28","slug":"new-javascript-minification-disabling-option-in-exo-platform-5-0","status":"publish","type":"post","link":"https:\/\/www.exoplatform.com\/blog\/new-javascript-minification-disabling-option-in-exo-platform-5-0\/","title":{"rendered":"New Javascript minification disabling option in eXo Platform 5.0"},"content":{"rendered":"<p>Thanks to its built-in <a href=\"https:\/\/docs.exoplatform.org\/\" target=\"_blank\" rel=\"noopener\">Javascript module support<\/a>, <strong>eXo Platform<\/strong> allows to easily integrate any custom or third-party Javascript. The script must be declared in the file WEB-INF\/gatein-resources.xml of your <strong>extension webapp<\/strong>:<\/p>\n<pre class=\"lang:js decode:true \">&lt;module&gt;\n    &lt;name&gt;myscript&lt;\/name&gt;\n    &lt;script&gt;\n        &lt;path&gt;\/javascript\/myscript.js&lt;\/path&gt;\n    &lt;\/script&gt;\n&lt;\/module&gt;<\/pre>\n<p>and can then be injected in any other page, portlet or other script:<\/p>\n<pre class=\"lang:js decode:true \">(function(myscript) {\n    myscript.doWhateverYouWant();\n    ...\n})(myscript);<\/pre>\n<p>The declared javascript files are automatically minified to reduce their size and therefore the size of resources fetched in web pages. This is a good practice but it can cause issues when the script is not compatible with the minifier used in <strong>eXo Platform<\/strong> (<a href=\"https:\/\/developers.google.com\/closure\/compiler\/\" target=\"_blank\" rel=\"noopener\">Google Closure Compiler<\/a>). For example, this issue <a href=\"https:\/\/www.exoplatform.com\/blog\/getting-started-with-reactjs-and-exo-platform-portlet-development\/\">has been discovered for React.js (chapter \u201cIncompatibility with the GateIn minifier\u201d)<\/a>.<br \/>\nIn eXo Platform 5.0 we added a new option in the Javascript module configuration to disable the minification: <i>minify<\/i>. The default value is set to true to keep backward compatibility.<\/p>\n<pre class=\"lang:js decode:true \">&lt;module&gt;\n    &lt;name&gt;myscript&lt;\/name&gt;\n    &lt;script&gt;\n        &lt;minify&gt;false&lt;\/minify&gt;\n        &lt;path&gt;\/javascript\/myscript.js&lt;\/path&gt;\n    &lt;\/script&gt;\n&lt;\/module&gt;<\/pre>\n<p>When the <i>minify<\/i> option is set to false, the script is injected as is, without any alteration. It allows to package your already <strong>minified script<\/strong>, with the source map files, using your favorite tool (webpack, \u2026).<\/p>\n<p>We believe this will make third parties\u2019 <strong>Javascript libraries<\/strong> easier to integrate and therefore <strong>improve the developers\u2019 experience<\/strong>.<\/p>\n<div>\n<div class=\"adv-events\" style=\"background: #476fad; padding: 30px 20px; color: white;\">\n<div class=\"media\">\n<div class=\"pull-right\"><a title=\"eXo Community\" href=\"https:\/\/community.exoplatform.com\/portal\/dw\/\" target=\"_blank\" rel=\"noopener\"><br \/>\n<img decoding=\"async\" class=\"size-full wp-image-6587 alignright\" style=\"border: none;\" src=\"https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2016\/02\/tribe.png\" alt=\"Join The eXo Tribe\" height=\"120px\" \/><br \/>\n<\/a><\/div>\n<div class=\"media-body\">\n<div class=\"media-heading\"><a title=\"eXo Tribe\" href=\"https:\/\/community.exoplatform.com\/portal\/dw\/\" target=\"_blank\" rel=\"noopener\">Join The eXo Tribe<\/a><\/div>\n<p><a href=\"https:\/\/community.exoplatform.com\/portal\/dw\/\" target=\"_blank\" rel=\"noopener\"><br \/>\nRegister for our Community to Get updates, tutorials, support, and access to the Platform and add-on downloads. <strong>Sign in Now!<\/strong><br \/>\n<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"Thanks to its built-in Javascript module support, eXo Platform allows to easily integrate any custom or third-party Javascript. The script must be declared in the file WEB-INF\/gatein-resources.xml of your extension webapp: &lt;module&gt; &lt;name&gt;myscript&lt;\/name&gt; &lt;script&gt; &lt;path&gt;\/javascript\/myscript.js&lt;\/path&gt; &lt;\/script&gt; &lt;\/module&gt; and can then be injected in any other page, portlet or other script: (function(myscript) { myscript.doWhateverYouWant(); &#8230; })(myscript); [&hellip;]","protected":false},"author":7,"featured_media":15533,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":[],"categories":[819],"tags":[606,711,827],"lang":"en","translations":{"en":15532},"pll_sync_post":[],"_links":{"self":[{"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/posts\/15532"}],"collection":[{"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/comments?post=15532"}],"version-history":[{"count":0,"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/posts\/15532\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/media\/15533"}],"wp:attachment":[{"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/media?parent=15532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/categories?post=15532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/tags?post=15532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}