how to not load unnecessary scripts ?

vincent3569 Member, Translator
hi
is there a way to not load unnecessary scripts in some pages ?
for example, googlemap plugin is enabled, but functions are used only on album page and not used on other pages (gallery, images, news, pages,...).

Comments

  • acrylian Administrator, Developer
    Not really, you actually have to code that into the plugin's options. See the options of the colorbox and slideshow plugins. Of course you can also hardcode the disabling but that will cause even more confusion if people want to use it elsewhere.
  • If the plugin "Knows" what pages it can be used from it can make the selection so long as it is a "theme" or "feature" plugin. But such "knowledge" is somewhat risky--who knows what a theme might want to do. The color box technique also works, but in my opinion it is quite cumbersome.

    You could disable the plugin then cause it to be loaded from your album's script. But this technique may not work depending on the plugin. For instance most "class" plugins would not work this way.

    If you do choose to try this, be sure that the plugin is not loaded from a function or all its global variables will become local to that function.

    Another consideration is that only the main plugin script is loaded, so that code could be streamlined and only load supporting code if a function is invoked.
Sign In or Register to comment.