Hi.
Working with various WordPress websites (freelancing), I noticed something that bothers me for a while
I have seen a lot of codecanyon plugins and themeforest themes which load all the scripts they need on ALL admin pages. Not only on the page where needed, but on ALL admin pagesâŠOne theme doing this is even in top 20 on themeforest, I will not name it
Why is this wrong:
Example 1:
For instance, if the theme/plugin loads google maps API on ALL admin pages, even where the theme/plugin doesnât need it, it will break other map plugins - this is because Google Maps throws an error and doesnât work if their API is loaded twice on a page.
Example 2:
Just imagine that a theme incorporates a lot of shortcodesâŠFor this, itâs loading various jQuery scripts and jQuery plugins that arenât loaded by default by WordPress (jquery-ui-dialog, file-upload, pick-a-date, etc). And itâs loading them on ALL admin pagesâŠWhy? I donât now.
Now just imagine that the end user will install other plugins which also load their scriptsâŠ
You can imagine how slow the admin pages will be. Not to name the conflictsâŠ
I could give more examples, but here is an article showing one way to do this correctly, itâs applicable both for theme and plugin authors
You can google to find other solutions, but please stop loading your scripts and styles on ALL admin pages! The buyers will thank you in the end!