Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Make Activate/Deactivate plugins and themes super fast! #4373

Closed
mattab opened this Issue · 8 comments

4 participants

@mattab
Owner

When Activating or deactivating a plugin, on the new page view, the Javascript and CSS file will be re-processed. Currently it takes up to 20 secondes (ouch)! This is because the JS and CSS files are huge in size: they include all core files, as well as third party plugins files.

Proposed solution:

  • All JS and CSS from "Core" plugins (see method isPluginBundledWithCore) is stored in the getJs and getCSs as currently
  • All JS and CSS from "Third Party plugins" are located in a new getJsPlugins and getCssPlugins

This new file is very small (since there are few third party plugins, especially atm). This file is easy and fast to re-process.

Notes:

  • When a Core plugin is enabled/disabled, delete core css+js files.
  • When a third party plugin is enabled/disabled, delete new plugin css+js file
  • Check that enabling/disabling plugins will only re-process the two small css/js files, therefore clicking should be 1-2 seconds at most.
@JulienMoumne
Collaborator

Dividing Less files would remove the ability for third-party plugins to override global Less variables.

Furthermore, most of the time is spent in minifying JavaScript files.

We will only separate JavaScript files.

An additional improvement will be committed :activating/deactivating plugins without JavaScript files will no longer trigger a full merging process.

@mattab
Owner

it's now slick to enable third party plugins & themes...

Very impressive change, full test driven, very well done Julien!

@mattab
Owner

fbd4675

Refs #1640 Adding jshrink to LEGALNOTICE + update help text

@mattab
Owner

In 3910272: Refs #4373 The getAssets calls the dispatcher with a plugin that cannot be loaded. catching exception when trying to "uninstall" the plugin.

@tsteur
Owner

In ca4779f: refs #4373 fixes the merged assets file was only generate if it did not exist before and fix it also was not regenerated if a plugin was not updated. Therefore include the version number in the cache buster.

@tsteur
Owner

In 8e9f6fc: refs #4373 I had to make this change to force reloading the css in case the compiled css changes without a version change

Following scenario:
There is a plugin that generates css/less files dynamically from time to time but the Plugin version does not change as there is no plugin update. Only the less file changes. When the less file changes, the plugin deletes the merged asset file as well.

The current cache buster is based on Piwik version + Plugin versions. That means, when a less file changes but no version the browser will still use the "cached CSS" as the cache buster does not change.

Therefore I have to build a cacheBuster value based on the content of the compiled CSS file to invalidate the cached CSS file in the browser and to force the reloading. As far as I can see this change does not have any huge performance implications as it builds a hash based on the already compiled CSS file and only tries to regenerate the compiled CSS file if it does not exist.

@tsteur
Owner

In 6f325aa: refs #4373 somehow my previous commit did not work. need this method public for my previous change in the view

@mattab mattab added this to the 2.0 - Piwik 2.0 milestone
@JulienMoumne JulienMoumne was assigned by mattab
@sabl0r sabl0r referenced this issue from a commit in sabl0r/piwik
@JulienMoumne JulienMoumne fixes #4373, #1640 6624e27
@sabl0r sabl0r referenced this issue from a commit in sabl0r/piwik
@mattab mattab Refs #4373 The getAssets calls the dispatcher with a plugin that cann…
…ot be loaded. catching exception when trying to "uninstall" the plugin.
3910272
@sabl0r sabl0r referenced this issue from a commit in sabl0r/piwik
@tsteur tsteur refs #4373 fixes the merged assets file was only generate if it did n…
…ot exist before and fix it also was not regenerated if a plugin was not updated. Therefore include the version number in the cache buster.
ca4779f
@sabl0r sabl0r referenced this issue from a commit in sabl0r/piwik
@tsteur tsteur refs #4373 I had to make this change to force reloading the css in ca…
…se the compiled css changes without a version change

Following scenario:
There is a plugin that generates css/less files dynamically from time to time but the Plugin version does not change as there is no plugin update. Only the less file changes. When the less file changes, the plugin deletes the merged asset file as well.

The current cache buster is based on Piwik version + Plugin versions. That means, when a less file changes but no version the browser will still use the "cached CSS" as the cache buster does not change. 

Therefore I have to build a cacheBuster value based on the content of the compiled CSS file to invalidate the cached CSS file in the browser and to force the reloading. As far as I can see this change does not have any huge performance implications as it builds a hash based on the already compiled CSS file and only tries to regenerate the compiled CSS file if it does not exist.
8e9f6fc
@sabl0r sabl0r referenced this issue from a commit in sabl0r/piwik
@tsteur tsteur refs #4373 somehow my previous commit did not work. need this method …
…public for my previous change in the view
6f325aa
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.