1

I'm using a really simple and fast theme in order to reach a good speed score, so i'm not using any visual composer, but writing my own sections in pages via html

i have some sections and cta that i'd like to repeat identical around the site so i had the idea of placing the html for each block inside a shortcode and then in the pages i just paste the shortcode for them where i need em.

first of all, is this a ok practice?

secondly, in terms of page loading speed is it ideal as i did to create these shortcodes (which will inject html in the dom basically) in my child-theme function.php or should i create a plugin with all the shortcodes instead?

0

It's an OK practice but in some cases could be turned to a worst case scenario!
Using shortcodes to generate blocks of HTML is the reason they exist, especially when you need some dynamic HTML generation (using attributes in the shortcode).

In conclusion, a normal shortcode usage is totally OK, however you should avoid putting hundreds of shortcodes in one page, otherwise it causes poor performance on the website.

2
  • 1
    thanks, i indeed ended up creating them only for repeatable sections, like 4-5 at max on some pages, but i created a dedicated php file for all the shortcodes, to keep the function.php cleaner, and the site rolls a 92/100 mobile PSI right now, with woocommerce and all, for a starter plan shared hosting ain't bad – Robert Feb 6 '20 at 0:14
  • Yeah that's totally fine. P.S Forgot to congrats you on joining the community :) – Yashar Feb 7 '20 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.