Load the plugin only in pages or articles that use it to increase the speed of the site
It would be nice and practical to add the option to load the plugin only where it’s needed, since it still consumes loading resources even on pages where it isn’t used. As shown in the attachment, it’s being loaded first on my website and slows down the overall speed.
Thank you for your attention and fantastic plugin.
Best regards
Hi @seremailragno, thanks for reaching out.
Yes the assets are registered with WordPress globally. Though they will only be loaded once by the browser and then cached, so on subsequent page loads the browser already has them and so only needs to download them once.
An added benefit of them being registered globally is this is that perfromance plugins can detect them and combine/compress them with other site assets to improve load times by only downloading one set of assets, instead of many.
The alternative would be to load Waymark only if a Waymark Shortcode is present on the page, which is possible but may cause other issues. Because Waymark Maps are displayed using the Shortcode, when a page loads WordPress does not know if the assets are necessary until it encounters a Shortcode. Therefore Waymark would need to be loaded at the very last minute, which could delay the loading of Maps and may cause issues when multiple Maps are present.
I noticed in your screenshot that it lists two different versions of the plugin (v1.5.8 & 1.5.7) both being loaded on your page, which is not the correct behaviour. I took a quick look at your page and can see that Waymark is being loaded manually at the very top of your HTML:
<!DOCTYPE html>
<html lang="it-IT" prefix="og: https://ogp.me/ns#">
<head>
<script src="/wp-content/plugins/waymark/waymark-js/dist/js/waymark-js.min.js?ver=1.5.7" async></script>
This should not be necessary as it is handled by the plugin. Loading this twice, each with a different ?ver= in the URL will force the browser to download the same file twice, which is not good for performance. Fixing this would be a big gain in terms of page load.
I hope this helps.
Thank you so much, Joe, for your reply. You’re right — I’ve made the change you suggested.