Is there some tool (or Rails itself) that can minify HTML (like what Jammit does for CSS and JS files) ?
Secondarily, what is the best practice here, and is it even worth minifying the html? (this is for a site that will be served to mobile phones, so keeping weight down is important)
Click on the URL button, Enter URL and Submit. Users can also minify HTML files by uploading the file. Minify HTML Online works well on Windows, MAC, Linux, Chrome, Firefox, Edge, and Safari.
Minify your code using Notepad++ Simply do the following: Edit > Blank Operations > Trim Header and Trailing Space. Edit > Blank Operations > Remove Unnecessary Blank and EOL.
Minification means to minimize code (HTML, CSS, JS) and markup in your web pages and script files. This reduces load times and bandwidth usage on websites. Moreover, it improves site speed and accessibility. Additionally, a user can access your website even with a limited data plan.
Well, you can remove most white space by using the HAML gem and the following lines in your config/application.rb
file:
Haml.init_rails(binding)
Haml::Template.options[:format] = :html5
Haml::Template.options[:ugly] = true
More information: http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#ugly-option
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With