-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SFT-1409]: Reducing the file-size of freeform.js (#1641)
* feat(SFT-1409): optimizing front-end js size * feat(SFT-1409): optimizing all freeform scripts * removing `axios` dependency * removing `lodash` dependency * removing `core-js` polyfills * chore(SFT-1409): updated changelog --------- Co-authored-by: kjmartens <[email protected]>
- Loading branch information
1 parent
61dec48
commit 16a3297
Showing
19 changed files
with
449 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...ges/plugin/src/Bundles/Fields/Implementations/CalculationField/CalculationFieldBundle.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Solspace\Freeform\Bundles\Fields\Implementations\CalculationField; | ||
|
||
use Solspace\Freeform\Events\Forms\CollectScriptsEvent; | ||
use Solspace\Freeform\Events\Forms\RenderTagEvent; | ||
use Solspace\Freeform\Fields\Implementations\Pro\CalculationField; | ||
use Solspace\Freeform\Form\Form; | ||
use Solspace\Freeform\Library\Bundles\FeatureBundle; | ||
use yii\base\Event; | ||
|
||
class CalculationFieldBundle extends FeatureBundle | ||
{ | ||
private const SCRIPT_PATH = 'js/scripts/front-end/fields/calculation.js'; | ||
|
||
public function __construct() | ||
{ | ||
Event::on( | ||
Form::class, | ||
Form::EVENT_COLLECT_SCRIPTS, | ||
[$this, 'collectScripts'], | ||
); | ||
|
||
Event::on( | ||
Form::class, | ||
Form::EVENT_RENDER_BEFORE_CLOSING_TAG, | ||
[$this, 'attachScripts'], | ||
); | ||
} | ||
|
||
public function collectScripts(CollectScriptsEvent $event): void | ||
{ | ||
$event->addScript('field.calculation', self::SCRIPT_PATH); | ||
} | ||
|
||
public function attachScripts(RenderTagEvent $event): void | ||
{ | ||
if (!$event->isGenerateTag()) { | ||
return; | ||
} | ||
|
||
$form = $event->getForm(); | ||
if (!$form->getLayout()->hasFields(CalculationField::class)) { | ||
return; | ||
} | ||
|
||
$event->addScript(self::SCRIPT_PATH); | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
packages/plugin/src/Resources/js/scripts/front-end/fields/calculation.js
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/plugin/src/Resources/js/scripts/front-end/payments/stripe/elements.js
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/plugin/src/Resources/js/scripts/front-end/plugin/freeform.js
Large diffs are not rendered by default.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
packages/plugin/src/Resources/js/scripts/front-end/plugin/freeform.js.LICENSE.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.