You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! 👋 I’m currently exploring PHP-based content management systems to assist in implementing my PHP minification project to them. It seems HTMLy doesn’t have a plugin feature, even using Composer to add my project as a dependency doesn’t seem to be that seamless to do. It seems the only way to implement it in HTMLy is to do it manually.
Here are the steps you can do to dynamically minify the HTMLy layout using my project. I assume you already have a live HTMLy site.
Step 1
Go to the .\system\includes\ folder, then install my project as .\system\includes\minify\. You can use Git to install it, or just download it manually and then put it in the folder. Example when using Git to install my project:
cd system/includes
git clone https://github.com/taufik-nurrohman/minify.git --depth 1
Step 2
Go to .\system\includes\dispatch.php file the open it with your code editor.
On line 428, wrap the trim(ob_get_clean()) part with my minification function like this:
echox\minify\h_t_m_l(trim(ob_get_clean()));
Step 3
Clear cache, then visit the site! Have a look at the source code to see that your site is now being minified by my project implementations 😉
Note
The HTML minifier will generally remove all white-spaces between HTML tags, but in some cases it will leave a space between two nodes, such as when an <img> element is preceded by text and a space, or followed by a space and text. You may experience some undesirable results like this, but it is not really a bug:
Compare the part of it where I have marked it in red and in green. The solution to avoid this problem is to make sure that each part of the separation between the PHP code and the inline HTML code is preceded or followed by a space.
If you want to keep a space, then place the opening PHP tag right after the inline HTML code or the closing PHP tag right before the inline HTML code:
Hello! 👋 I’m currently exploring PHP-based content management systems to assist in implementing my PHP minification project to them. It seems HTMLy doesn’t have a plugin feature, even using Composer to add my project as a dependency doesn’t seem to be that seamless to do. It seems the only way to implement it in HTMLy is to do it manually.
Here are the steps you can do to dynamically minify the HTMLy layout using my project. I assume you already have a live HTMLy site.
Step 1
Go to the
.\system\includes\
folder, then install my project as.\system\includes\minify\
. You can use Git to install it, or just download it manually and then put it in the folder. Example when using Git to install my project:cd system/includes git clone https://github.com/taufik-nurrohman/minify.git --depth 1
Step 2
Go to
.\system\includes\dispatch.php
file the open it with your code editor.Right after line 4, add this line:
On line 426, wrap the
ob_get_contents()
part with my minification function like this:On line 428, wrap the
trim(ob_get_clean())
part with my minification function like this:Step 3
Clear cache, then visit the site! Have a look at the source code to see that your site is now being minified by my project implementations 😉
Note
The HTML minifier will generally remove all white-spaces between HTML tags, but in some cases it will leave a space between two nodes, such as when an
<img>
element is preceded by text and a space, or followed by a space and text. You may experience some undesirable results like this, but it is not really a bug:Compare the part of it where I have marked it in red and in green. The solution to avoid this problem is to make sure that each part of the separation between the PHP code and the inline HTML code is preceded or followed by a space.
If you want to keep a space, then place the opening PHP tag right after the inline HTML code or the closing PHP tag right before the inline HTML code:
Before
After
The text was updated successfully, but these errors were encountered: