简体   繁体   中英

Will replacing php coding, in the index.php file with `get_template_part` tags, reduce website performance?

My index.php file currently includes content such as:

  • Latest Products
  • Product Testimonials
  • Subscribe to us
  • Blogs

Rather than have the entire coding for this, placed into my index.php file, I would like to create a template file for each 'section' and then call it in the index.php file, using the get_template_part tag.

So much so, my index.php would then become a file housing a series of get_template_part entries.

Is anyone aware of any issues that this may cause, such as website load speed or any compatibility issues?

Since originally posting this question, I have experimented with the layout of the index.php file, where I used Google's PageSpeed Insights and Pingdom to measure any performance changes.

Firstly, I placed the following content into the index.php file:

  • Latest Products
  • Product Testimonials
  • Subscribe to us
  • Blogs

I then took out the above content and then placed the content into assigned Templates files. I then entered the appropriate get_template_part tags into the 'index.php' files, as to call each Template file.

Whilst there was a slight reduction in page load speed, it was negligible. On one occasion, the change in PageSpeed was a reduction of speed of 0.0003s.

Of course, it is up to the site creator on how they want to go about the creation for their website but I feel this is a good trade off, considering it would result in a more organised website.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM