What will be faster - plugin, html or shortcode?

I am curious if anyone has experience in improving a WordPress site to make it as quick as possible to load a page, and which approaches work better than others.

For example, let's add social media buttons to the footer. What would be the fastest? What will be the greatest resistance?

  • Plugin - there are some plugins, including for Genesis, which allow the user to enter a URL on social networks, and then the icon and link are generated as a widget. I am wondering if this will be a big load if CSS and files for all icon sets are loaded instead of the ones that are used, plus any additional plug-in code that executes.

  • HTML in widgets . With something simple, I thought that code could be created and added to a text widget, with images stored in theme folders. This can be a little risky, because I saw how the HTML in the widget is blown out, and clients can accidentally change the wrong part.

  • HTML in the subject . I try to avoid hard-coding elements that the client might want to update, but it seems very effective if it is not included in the widget area by default, in which case would you not widget it?

  • Shortcode - with hard-coded elements that will need to be used in several different places, I thought that creating fractional code might be a good option. But does anyone know if shortcodes can drag a site? Are all elements in the shortcode file set, even if this short code is not called on this page? I try to get rid of unnecessary CSS or scripts when necessary, but I don't know if shortcodes will only name the called piece. Somebody knows?

Thanks, any information or advice is appreciated.

+4
source share
3 answers

Personally, I use the theme options page, which displays HTML code if the administrator fills in this information. This is not the fastest, but it is great for control and simplicity.

+1
source

Unfortunately, there is no black and white answer, because there are many factors that come into play.

For example, server-side rendering of content in many cases is faster than rendering on the interface, but to a large extent depends on the speed of your server. If you are on a cheap basis, sharing hosting (like many of us), the server side may be slower.

There are 7 things I recommend to everyone to improve the site:

  • Combine. Combining similar files together.
  • Minimize. Remove spacing, line breaks and comments from files.
  • Smush Delete unnecessary data from image files.
  • Font icons. Icon fonts are a lighter, faster alternative to image-based images.
  • Squeeze. Reduce the file size to 70%.
  • Cache Instructing browsers to store static assets stored locally so that they do not need to be reloaded every time they visit your site.
  • Page structure. Customize the location of CSS and JavaScript files to speed up rendering.

If you want to know more about this, I wrote a fairly detailed article on faster WordPress sites. I personally used these tips to create several sites that load in less than 2 seconds on a cheap shared hosting.

http://gomakethings.com/high-performance-websites/

+1
source

1- Html and PHP: for social networks, you put them in another file, for example social-Blox.php, then call it

<?php include(locate_template( 'templates/social-Blox.php' ));?> 

you now have a social in a separate file that you can use in many places and it is still very bright without loading plugins or any thing

after that inside social-Blox.php you do not add only html NO. parts that will be changed later, you can use ACF parameters or themes ... make them dynamic, for example, links for facebook and twitter ... etc.

 <a href="<?php the_field("facebook",105); ?>" class="icoFacebook a_t" title="Facebook"> <i class="fa fa-facebook"></i> </a> 

fields that need to be changed, for example, on social networks I add them to a user page, such as a “shared page”, so the client changes them from there, I use these values ​​every time they are like this and in these files ...

here you reuse file blocks ... and reuse data ... with one control panel.

2- widget and short code: I don’t like that it needs more time to develop its difficult reuse and allow the client to use it in their work.

Plugins with plugins are always a big problem for performance, the less you use them better ...

  • There are large well-known plugins that you cannot replace or recreate, like AFC, mailPoet ...
  • There are small plugins, but you have the idea you need and grab the plugin. Basically its files are 1, you need PHP, and you need css and JS, and add it to BOlX, as I explain earlier (in this case you will take a maximum of 50% of the plugin code), and now the code is yours not closing a block with a process in which you do not need problems that you do not know ...
+1
source

Source: https://habr.com/ru/post/1496680/


All Articles