Skip to content

Commit

Permalink
Merge pull request #12 from magefan/11052-speed-optimization-extensio…
Browse files Browse the repository at this point in the history
…n-v2

11052 speed optimization extension v2
  • Loading branch information
magefan authored Nov 18, 2024
2 parents a422095 + 53d6b99 commit b67bc1e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
12 changes: 4 additions & 8 deletions Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,20 @@ public function isBundlingEnabled(string $storeId = null): bool

/**
* Retrieve true if bundling optimization is enabled
*
* @param string|null $storeId
* @return bool
*/
public function isBundlingOptimizationEnabled(string $storeId = null): bool
public function isBundlingOptimizationEnabled(): bool
{
return (bool)$this->getConfig(self::XML_PATH_JAVASCRIPT_BUNDLING_OPTIMIZATION_ENABLED, $storeId);
return (bool)$this->getConfig(self::XML_PATH_JAVASCRIPT_BUNDLING_OPTIMIZATION_ENABLED);
}

/**
* Retrieve included in bundling JS
*
* @param string|null $storeId
* @return string
*/
public function getIncludedInBundling(string $storeId = null): string
public function getIncludedInBundling(): string
{
return (string)$this->getConfig(self::XML_PATH_JAVASCRIPT_BUNDLING_INCLUDED_IN_BUNDLING, $storeId);
return (string)$this->getConfig(self::XML_PATH_JAVASCRIPT_BUNDLING_INCLUDED_IN_BUNDLING);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion Plugin/Deploy/Package/Bundle/RequireJsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public function __construct(
*/
public function aroundAddFile(RequireJs $subject, callable $proceed, $filePath, $sourcePath, $contentType)
{
$jsOptimization = $this->config->isEnabled() && $this->config->isBundlingOptimizationEnabled();

$jsOptimization = $this->config->isBundlingEnabled() && $this->config->isEnabled();
if ($jsOptimization) {
$allowedFiles = $this->getAllowedFiles();

Expand All @@ -55,6 +55,7 @@ public function aroundAddFile(RequireJs $subject, callable $proceed, $filePath,
return true;
}
}

return $proceed($filePath, $sourcePath, $contentType);
}

Expand Down
4 changes: 2 additions & 2 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@
<backend_model>Magefan\RocketJavaScript\Model\Config\Backend\DevSettings</backend_model>
<comment>Static content deployment is a requirement after option change</comment>
</field>
<field id="enable_js_bundling_optimization" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="20" translate="label" type="select" canRestore="1">
<field id="enable_js_bundling_optimization" showInDefault="1" showInStore="0" showInWebsite="0" sortOrder="20" translate="label" type="select" canRestore="1">
<label>Enable Bundling Optimization</label>
<depends>
<field id="enabled">1</field>
</depends>
<comment>Static content deployment is a requirement after option change</comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="included_in_bundling" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="30" translate="label" type="textarea" canRestore="1">
<field id="included_in_bundling" showInDefault="1" showInStore="0" showInWebsite="0" sortOrder="30" translate="label" type="textarea" canRestore="1">
<label>Included In Bundling</label>
<depends>
<field id="enabled">1</field>
Expand Down

0 comments on commit b67bc1e

Please sign in to comment.