![]() These codes are huge because they do a lot of work: Other codes lurk in your WordPress template, namely JavaScript and CSS. The Text tab can be enlightening for one thing, it shows just how much of the heavy lifting WordPress does for you! It displays the page’s HTML code, which is the actual language of the web. In fact, it’s not all that unusual for WordPress hosts to learn that their clients have never checked out the HTML (Text) tab. One thing that makes WordPress so popular is that it does the coding for the writer. We also would like to guide you to FixRunner guide on how to improve WordPress speed without any coding knowledge. Luckily, you don’t have to learn code to fix this – repairing code is easier than you may think. If you’ve recently noticed a slowdown in your website, you may have received advice such as “combine CSS coding” or “external JavaScript file not working.” Messages like these mean the codes on your website are slowing your site’s download time. I also included a code that prevents HTML compression on a specified by you domain, for example the local environment.Lots of things can slow down a WordPress site: too many large graphics, not enough bandwidth (something that can be optimized by a solid WordPress hosting service), and browser issues. It happens even when you prevent the code from running in the admin dashboard.Īdd_action(‘init’, ‘flhm_wp_html_compression_start’) ĭisabling CSS, JS and comments compression also didn’t help. Using add_action(‘init’, ‘flhm_wp_html_compression_start’) instead of add_action(‘get_header’, ‘flhm_wp_html_compression_start’) breaks creating and updating Gutenberg posts for me. Unfortunately, the above code breaks for me the current version of WordPress. Categories WordPress and Web Development Tutorials You can also find us on Freelancer if you need some help with your WordPress website or web development issues. If you enjoyed this tutorial, please be sure to follow us on Facebook and Twitter. Check and make sure all plugins and theme functionality is working properly. I highly recommend you check all aspects of your website after you add this code. Ob_start('flhm_wp_html_compression_finish') Īdd_action('get_header', 'flhm_wp_html_compression_start') Step 3: Make Sure Everything is WorkingĪfter you have added the code, you can check to see if the HTML is being minified on Google Chrome by right clicking the page and selecting “View page source.” If everything is working correctly, it should look like the example picture I gave at the top of this page. $str = str_replace("// The customizer requires postMessage and CORS (if the site is cross domain).",'',$str) įunction flhm_wp_html_compression_finish($html)įunction flhm_wp_html_compression_start() Protected function flhm_removeWhiteSpace($str) $this->flhm_bottomComment($html, $this->html) $this->html = $this->flhm_minifyHTML($html) $content = $this->flhm_removeWhiteSpace($content) If (!$overriding & $raw_tag != 'textarea') Protected function flhm_minifyHTML($html) $savings = ($raw-$compressed) / $raw * 100 Protected function flhm_bottomComment($raw, $compressed) The functions.php file will be inside your theme folder.Ĭopy and paste the code below inside your functions.php file and save. Go to the public_html/wp-content/themes/ and choose the folder of your current theme or child theme if you have created one. While you are logged into WordPress you can access and edit the functions.php file of your theme by going to Appearance > Editor and selecting Theme Functions on the right hand side of the page. There are 2 different ways we can edit the functions.php file in your child theme. Step 2: Edit your Child Theme functions.php File It removes the need to add custom snippets to your theme’s functions.php file. Code Snippets is an easy, clean and simple way to add code snippets to your site. If you prefer not to create a child theme or you do not feel comfortable doing this on your own, there is a great lightweight plugin you can use called Code Snippets. ![]() ![]() Also, any changes you make will not be deleted if your parent theme gets updated. Using a child theme will allow you to revert back to the parent theme if there are problems. Before we edit the functions.php file, it’s always best to create a child theme. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |