When we talk about web performance , the loading speed of the scripts is always analyzed, mainly with the aim of loading them through a CDN.
But how could we make any script from a WordPress site load with a CDN? Well, there is a solution.
How? Well, it’s quite simple, really. The base addresses are as follows:
I’m going to give a couple of examples to make it much simpler. If you have the Classic Editor plugin, and we analyze the trunk a little, we can see that there is a “js” folder. This would allow you to see that when the plugin is loaded, a file of the style a will surely be called:
This would be served directly from our hostname, which may not make it optimal… but we could call it from here:
This would also work when making specific calls to specific versions of the plugin:
In the same way, we can do with the files of the templates. In this case, I will take the example of Twenty Nineteen.
Okay, yes, all this is very good but … How to put it into practice? Well, there are several ways… one of them is directly through the developers of the plugins that could give you the option. By working as standard with any plugin, the plugin developer (or theme) could give you the option to upload from locally or through this CDN. You decide.
The other option, after a search through the repository, is to use this plugin called NGT jsDelivr CDN that does the work for you. Although perhaps one of the things that you may like the most is that this plugin not only replaces the code of plugins and themes, but also the core.
As you can see, you could launch an optimized version of all your sites with WordPress improving performance by making calls to this CDN.
By the way, I just tried and it also works with CSS.
You know… do you want to optimize your WordPress? Now you can do it.
About this document
This document is regulated by the EUPL v1.2 license, published in WP SysAdmin and created by Javier Casares. Please, if you use this content in your website, your presentation or any material you distribute, remember to mention this site or its author, and having to put the material you create under EUPL license.