{"id":2034,"date":"2013-10-18T16:52:23","date_gmt":"2013-10-18T12:52:23","guid":{"rendered":"http:\/\/www.dhtmlx.com\/blog\/?p=2034"},"modified":"2026-04-03T15:32:06","modified_gmt":"2026-04-03T12:32:06","slug":"tips-on-how-to-compile-dthmlx","status":"publish","type":"post","link":"https:\/\/dhtmlx.com\/blog\/tips-on-how-to-compile-dthmlx\/","title":{"rendered":"Tips on How to Minify the DHTMLX Files"},"content":{"rendered":"<p>\n        <div class=\"info-block\">\n            <div class=\"info-icon\">\n                <svg viewBox=\"0 0 14 16\">\n                    <path fill-rule=\"evenodd\" d=\"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z\"><\/path>\n                <\/svg>\n\n                INFO\n            <\/div>\n\n            <div class=\"info-content\">\n                <p>\n                    If you are using an outdated version of DHTMLX Suite 5 and require the documentation for it, \n                    please <a href=\"https:\/\/dhtmlx.com\/docs\/contact.shtml\" title=\"\">contact us<\/a>, <br \/>and we will send it to you.\n                <\/p>\n            <\/div>\n        <\/div>\n    <br \/>\nThis post is for developers who work closely with the DHTMLX library and would like to use its advantages in a most proper way. <\/p>\n<p>As you might already know, there are a few options to include the DHTMLX library on a page: <\/p>\n<ul>\n<li>use a set of separate .js files of all components used on a page (this is the best option for the development stage, as only separate files include uncompressed, readable code; these files are stored in the &#8216;<strong>sources<\/strong>&#8216; folder of each component package)<\/li>\n<li>use the complete <em>dhtmlx.js<\/em> file that includes all components and all available functionality (stored in the <strong>dhtmlx_std_full.zip<\/strong> \/ <strong>dhtmlx_pro_full.zip<\/strong> archive of the <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxSuite\/\">JavaScript widget library<\/a>) package<\/li>\n<li>use compiled custom <em>dhtmlx.js<\/em> file that includes only required components and features (this option is the best for the final app, since it greatly reduces the file size, removes the unnecessary functionality, and allows you to load only one .js\/.css file, which improves overall application performance)<\/li>\n<\/ul>\n<p>&nbsp;<br \/>\nWhen using the DHTMLX components, you sometimes apply for the help and ask us for some kind of customization or bug fixes. Often, you modify the code by yourself.  After getting or making the required changes, you face the question &#8211; how to add these changes into the compiled <em>dhtmlx.js<\/em>?<\/p>\n<p>In this article, we would like to provide some useful tips on how you can handle the modified code and incorporate the changes into the compiled <em>dhtmlx.js<\/em> file. You will see that you can quickly add the modifications and generate the compressed .js\/.css file without a need to ask the support team to make it for you.<\/p>\n<h3>Development Stage<\/h3>\n<p>&nbsp;<br \/>\nAs we&#8217;ve mentioned before, we recommend using the components&#8217; source files while your project is on the development stage. You can find them in the &#8216;<strong>sources<\/strong>&#8216; folder (if you use dhtmlxSuite, check the separate folders of each component). Of course, in this case you will need to add more than one .js and .css files, but it will be much easier to debug the readable JavaScript code than the compressed files.<\/p>\n<p>To reduce the total size and the number of loaded files, you can include only the components used in your app without including other &#8220;heavy&#8221; stuff and unused functionality.<\/p>\n<p>Anyway, you can still use the compiled <em>dhtmlx.js<\/em>, if you wish.<\/p>\n<h3>Changes\/Fixes\/Customization<\/h3>\n<p>&nbsp;<br \/>\nWhen you need some kind of fix, improvement, or custom feature, and apply for help, our support team often asks for a complete demo. Note that we need the exact files you are using in your app (maybe they already contain some changes). In this case, it&#8217;s better to use the sources. The compiled <em>dhtmlx.js<\/em> file will just allow us to determine the problem but rarely to fix it.<\/p>\n<h3>How to Merge Changes<\/h3>\n<p>&nbsp;<br \/>\nIf you have modified the .js files (say, dhtmlxform.js or dhtmlxgrid.js), it&#8217;s time to add them into your project. It won&#8217;t be a problem if you&#8217;re using the separate component files: just overwrite or merge the necessary files.<\/p>\n<p>If you&#8217;re using the compiled <em>dhtmlx.js<\/em> file, there is a way to recompile it. The dhtmlxSuite package (<a href=\"https:\/\/dhtmlx.com\/x\/download\/regular\/dhtmlxSuite.zip\">download<\/a>) contains the <strong>libCompiler<\/strong> tool (stored in the &#8216;libCompiler&#8217; folder). Follow these simple steps to integrate your changes into <em>dhtmlx.js<\/em>:<\/p>\n<ul>\n<li>Unpack the content of the zip package into any folder under web_server+PHP<\/li>\n<li>Find the sources for the components you want to update (replace existing files with the fixed ones &#8211; overwrite or merge)<\/li>\n<li>Open in a web browser:<br \/>\nhttp:\/\/localhost_or_whats_your_host_is\/folder_where_you_unpack_dhtmlx_zip\/libCompiler\/<\/li>\n<\/ul>\n<p>&nbsp;<br \/>\nNote: you need Java to be installed (.jar file will be executed) for better result.<\/p>\n<p>This is the user interface of the libCompiler tool for the DHTMLX framework:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/10\/libcompiler11.jpg\" alt=\"LibCompiler for DHTMLX\" title=\"LibCompiler for DHTMLX\" width=\"606\" height=\"504\" class=\"aligncenter size-full wp-image-2047\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/10\/libcompiler11.jpg 606w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/10\/libcompiler11-300x249.jpg 300w\" sizes=\"auto, (max-width: 606px) 100vw, 606px\" \/><\/p>\n<p>So, how to use the <strong>libCompiler<\/strong>:<\/p>\n<ul>\n<li>Use the folder tree at the left to select components and separate features that you want to include on the page (for the complete suite select &#8220;suite full&#8221; from the dropdown above the tree).<\/li>\n<li>In the right panel, you can select the skin: SkyBlue, Web, or Terrace.<\/li>\n<li>Make sure that the folder <strong>libCompiler\/export<\/strong> has read\/write permissions and press &#8220;<strong>generate<\/strong>&#8221; button on the toolbar.<\/li>\n<\/ul>\n<p>&nbsp;<br \/>\nThe <strong>libCompiler<\/strong> will generate a zip package with a single <em>dhtmlx.js<\/em>, <em>dhtmlx.css<\/em> and all necessary images. These generated files will include the selected DHTMLX components and functionality. The file size depends on the number of components you selected.<\/p>\n<p><!--more--><\/p>\n<h3>Compress Files Using Custom Scripts<\/h3>\n<p>&nbsp;<br \/>\nIf you feel the power and believe in your programming skills, you can write custom scripts to compress the source files for the final release branch. The advantage of this approach is that you will be able to compress the DHTMLX sources and your own JavaScript and CSS code in a single file, which is much better for application loading time and performance. <\/p>\n<p>The method described below is a bit old-school but it still works so you may give it a try. If you prefer to use the modern tools for JavaScript compilation, wait for our next article ;)<\/p>\n<p>So, back to our tips. On the development stage, you add the source file but you also need compiled <em>dhtmlx.js<\/em>, <em>dhtmlx.css<\/em> and your custom JavaScript and CSS code. Here is how you can compress the DHTMLX sources using a custom script on Linux. <\/p>\n<p>Check the <strong>libCompiler\/yui folder<\/strong> in the dhtmlxSuite package, it contains the file compiler.jar. We will need this file.<\/p>\n<p>To compile JavaScript files on Linux, use the following script (we will save it as a &#8220;<em>compile_js<\/em>&#8221; file &#8211; see the structure of files below):<\/p>\n<div class=\"codecolorer-container bash default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"bash codecolorer\"><span class=\"co0\">#!\/bin\/bash<\/span><br \/>\n<br \/>\n<span class=\"re2\">COMPILER<\/span>=compiler.jar; <br \/>\n<br \/>\n<span class=\"co0\"># generating JS<\/span><br \/>\n<br \/>\n<span class=\"re2\">RES_JS<\/span>=res<span class=\"sy0\">\/<\/span>compiled.js; <br \/>\n<br \/>\n<span class=\"kw3\">echo<\/span> <span class=\"re5\">-ne<\/span> <span class=\"st0\">&quot;&quot;<\/span> <span class=\"sy0\">&gt;<\/span> <span class=\"re1\">$RES_JS<\/span>;<br \/>\n<span class=\"kw2\">java<\/span> <span class=\"re5\">-jar<\/span> <span class=\"re1\">$COMPILER<\/span> ..<span class=\"sy0\">\/<\/span>dhtmlx<span class=\"sy0\">\/<\/span>dhtmlxLayout<span class=\"sy0\">\/<\/span>dhtmlxcommon.js <span class=\"sy0\">&gt;&gt;<\/span> <span class=\"re1\">$RES_JS<\/span><br \/>\n<span class=\"kw2\">java<\/span> <span class=\"re5\">-jar<\/span> <span class=\"re1\">$COMPILER<\/span> ..<span class=\"sy0\">\/<\/span>dhtmlx<span class=\"sy0\">\/<\/span>dhtmlxLayout<span class=\"sy0\">\/<\/span>dhtmlxcontainer.js <span class=\"sy0\">&gt;&gt;<\/span> <span class=\"re1\">$RES_JS<\/span><br \/>\n<span class=\"kw2\">java<\/span> <span class=\"re5\">-jar<\/span> <span class=\"re1\">$COMPILER<\/span> ..<span class=\"sy0\">\/<\/span>dhtmlx<span class=\"sy0\">\/<\/span>dhtmlxLayout<span class=\"sy0\">\/<\/span>dhtmlxlayout.js <span class=\"sy0\">&gt;&gt;<\/span> <span class=\"re1\">$RES_JS<\/span><br \/>\n<span class=\"kw2\">java<\/span> <span class=\"re5\">-jar<\/span> <span class=\"re1\">$COMPILER<\/span> ..<span class=\"sy0\">\/<\/span>dhtmlx<span class=\"sy0\">\/<\/span>dhtmlxForm<span class=\"sy0\">\/<\/span>dhtmlxform.js <span class=\"sy0\">&gt;&gt;<\/span> <span class=\"re1\">$RES_JS<\/span><\/div><\/div>\n<p>This script compresses the .js files and generates a single compiled.js file. In this example, we compile files for dhtmlxLayout and dhtmlxForm. If you need other DHTMLX components, add the corresponding files.<\/p>\n<p>Now, let&#8217;s compress the CSS code. In the CSS files of DHTMLX skins, we use relative paths for images so before compressing you need to remove extra &#8220;..\/&#8221; in the path to avoid the confusion in the compiled .js file that will link to the required images.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/10\/css-paths-1.png\" alt=\"CSS and path to images\" title=\"CSS and path to images\" width=\"606\" height=\"358\" class=\"aligncenter size-full wp-image-2045\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/10\/css-paths-1.png 606w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/10\/css-paths-1-300x177.png 300w\" sizes=\"auto, (max-width: 606px) 100vw, 606px\" \/><\/p>\n<p>We will remove &#8220;..\/&#8221; using a PHP script. Create a <em>parser.php<\/em> file:<\/p>\n<div class=\"codecolorer-container php default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"php codecolorer\"><span class=\"kw2\">&lt;?php<\/span><br \/>\n<span class=\"kw1\">if<\/span> <span class=\"br0\">&#40;<\/span><span class=\"re0\">$argc<\/span> <span class=\"sy0\">&gt;=<\/span> <span class=\"nu0\">2<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"re0\">$f<\/span> <span class=\"sy0\">=<\/span> <span class=\"kw3\">file_get_contents<\/span><span class=\"br0\">&#40;<\/span><span class=\"re0\">$argv<\/span><span class=\"br0\">&#91;<\/span><span class=\"nu0\">1<\/span><span class=\"br0\">&#93;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span> <br \/>\n&nbsp; &nbsp; <span class=\"re0\">$f<\/span> <span class=\"sy0\">=<\/span> <span class=\"kw3\">str_replace<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;..\/imgs\/&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"st0\">&quot;imgs\/&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"re0\">$f<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span> <br \/>\n&nbsp; &nbsp; <span class=\"kw3\">file_put_contents<\/span><span class=\"br0\">&#40;<\/span><span class=\"re0\">$argv<\/span><span class=\"br0\">&#91;<\/span><span class=\"nu0\">1<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span> <span class=\"re0\">$f<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span> <br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"sy1\">?&gt;<\/span><\/div><\/div>\n<p>This script removes the relative path for images so the compiled <em>dhtmlx.js<\/em> will find the required images for skins. The compiled .js file will be placed in the parent folder with the folder &#8216;<strong>images<\/strong>&#8216;. <\/p>\n<p>So in the generated file the path to the images will be changed from:<\/p>\n<div class=\"codecolorer-container css default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"css codecolorer\"><span class=\"kw1\">background-image<\/span><span class=\"sy0\">:<\/span> <span class=\"kw3\">url<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;..\/imgs\/dhxform_dhx_skyblue\/dhxform_btns.gif&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>to:<\/p>\n<div class=\"codecolorer-container css default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"css codecolorer\"><span class=\"kw1\">background-image<\/span><span class=\"sy0\">:<\/span> <span class=\"kw3\">url<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;imgs\/dhxform_dhx_skyblue\/dhxform_btns.gif&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>The CSS file will be placed in the same directory as the folder &#8216;<strong>images<\/strong>&#8216; and the folder &#8216;<strong>skins<\/strong>&#8216; will be removed. <\/p>\n<p>The script for compressing the CSS files (we will save it under &#8220;<em>compile_css<\/em>&#8221; name):<\/p>\n<div class=\"codecolorer-container bash default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"bash codecolorer\"><span class=\"co0\">#!\/bin\/bash<\/span><br \/>\n<br \/>\n<span class=\"re2\">COMPILER<\/span>=compiler.jar; <br \/>\n<br \/>\n<span class=\"co0\"># generating CSS<\/span><br \/>\n<br \/>\n<span class=\"re2\">RES_CSS<\/span>=res<span class=\"sy0\">\/<\/span>compiled.css <br \/>\n<br \/>\nK<span class=\"br0\">&#91;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#93;<\/span>=..<span class=\"sy0\">\/<\/span>dhtmlx<span class=\"sy0\">\/<\/span>dhtmlxLayout<span class=\"sy0\">\/<\/span>dhtmlxlayout.css<br \/>\nK<span class=\"br0\">&#91;<\/span><span class=\"nu0\">1<\/span><span class=\"br0\">&#93;<\/span>=..<span class=\"sy0\">\/<\/span>dhtmlx<span class=\"sy0\">\/<\/span>dhtmlxLayout<span class=\"sy0\">\/<\/span>skins<span class=\"sy0\">\/<\/span>dhtmlxlayout_dhx_skyblue.css<br \/>\nK<span class=\"br0\">&#91;<\/span><span class=\"nu0\">2<\/span><span class=\"br0\">&#93;<\/span>=..<span class=\"sy0\">\/<\/span>dhtmlx<span class=\"sy0\">\/<\/span>dhtmlxForm<span class=\"sy0\">\/<\/span>skins<span class=\"sy0\">\/<\/span>dhtmlxform_dhx_skyblue.css<br \/>\n<br \/>\n<span class=\"co0\"># first call parset to change imgs urls then compile<\/span><br \/>\n<br \/>\n<span class=\"kw3\">echo<\/span> <span class=\"re5\">-ne<\/span> <span class=\"st0\">&quot;&quot;<\/span> <span class=\"sy0\">&gt;<\/span> <span class=\"re1\">$RES_CSS<\/span>; <br \/>\n<br \/>\n<span class=\"kw1\">for<\/span> i <span class=\"kw1\">in<\/span> <span class=\"co1\">${K[@]}<\/span>; <span class=\"kw1\">do<\/span><br \/>\n&nbsp; &nbsp;<span class=\"kw2\">cp<\/span> <span class=\"re1\">$i<\/span> tmp.css; <br \/>\n&nbsp; &nbsp;php parser.php tmp.css; <br \/>\n&nbsp; &nbsp;<span class=\"kw2\">java<\/span> <span class=\"re5\">-jar<\/span> <span class=\"re1\">$COMPILER<\/span> tmp.css <span class=\"sy0\">&gt;&gt;<\/span> <span class=\"re1\">$RES_CSS<\/span>; <br \/>\n<span class=\"kw1\">done<\/span><br \/>\n<br \/>\n<span class=\"kw2\">rm<\/span> tmp.css<\/div><\/div>\n<p>This script processes each CSS file with our PHP script (removes &#8220;..\/&#8221; in image paths) and compressed the CSS files in a single file. <\/p>\n<p>Using this approach, you get compressed .js and .css files for the DHTMLX library. As for the images, you need to copy them manually or create a custom script.<\/p>\n<p>The structure of folders and files that should be used for this approach:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/10\/before.jpg\" alt=\"Files structure before compiling\" title=\"Files structure before compiling\" width=\"430\" height=\"515\" class=\"aligncenter size-full wp-image-2048\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/10\/before.jpg 430w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/10\/before-250x300.jpg 250w\" sizes=\"auto, (max-width: 430px) 100vw, 430px\" \/><\/p>\n<p>Where:<\/p>\n<ul>\n<li>\/compiler\/compile_js &#8211; script to compile the .js files<\/li>\n<li>\/compiler\/compile_css &#8211; script to compile the .css files<\/li>\n<li>\/compiler\/res\/ &#8211; the folder where results will be generated, make sure this folder have r\/w permissions<\/li>\n<li>\/compiler\/res\/imgs\/ &#8211; copy images from dhtmlx\/dhtmlx[NeededComponent]\/imgs\/* here<\/li>\n<li>\/dhtmlx\/ &#8211; unpacked dhtmlx.zip should be here<\/li>\n<\/ul>\n<p>&nbsp;<br \/>\nAfter compilation is over, you will have:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/10\/after.jpg\" alt=\"Files structure after compiling the files\" title=\"Files structure after compiling the files\" width=\"430\" height=\"515\" class=\"aligncenter size-full wp-image-2049\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/10\/after.jpg 430w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2013\/10\/after-250x300.jpg 250w\" sizes=\"auto, (max-width: 430px) 100vw, 430px\" \/><\/p>\n<p>Please feel free to ask any questions in the comments. If you try this custom scripts for compressing the .js and .css files, let us know about your experience. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post is for developers who work closely with the DHTMLX library and would like to use its advantages in a most proper way. As you might already know, &#8230;<\/p>\n","protected":false},"author":2,"featured_media":3404,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71,1],"tags":[33,14,10],"class_list":["post-2034","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","category-uncategorized","tag-all-posts","tag-tips","tag-dhtmlxsuite"],"_links":{"self":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2034","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/comments?post=2034"}],"version-history":[{"count":5,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2034\/revisions"}],"predecessor-version":[{"id":15352,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2034\/revisions\/15352"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media\/3404"}],"wp:attachment":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media?parent=2034"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/categories?post=2034"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/tags?post=2034"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}