定制 hryvinskyi/magento2-deferjs 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hryvinskyi/magento2-deferjs

Composer 安装命令:

composer require hryvinskyi/magento2-deferjs

包简介

N/A

README 文档

README

The module moves javascripts to the bottom of the page.

Latest Stable Version Total Downloads PayPal donate button Latest Unstable Version License Scrutinizer Code Quality Build Status

Installation Guide

Install by composer

composer require hryvinskyi/magento2-deferjs
bin/magento module:enable Hryvinskyi_Base
bin/magento module:enable Hryvinskyi_DeferJs
bin/magento setup:upgrade

Install download package

  1. Download module https://github.com/hryvinskyi/magento2-base "Clone or download -> Download Zip"
  2. Download this module "Clone or download -> Download Zip"
  3. Unzip two modules in the folder app\code\Hryvinskyi\Base and app\code\Hryvinskyi\DeferJs
  4. Run commands:
bin/magento module:enable Hryvinskyi_Base
bin/magento module:enable Hryvinskyi_DeferJs
bin/magento setup:upgrade
  1. Configure module in admin panel

General Settings

To get the access to the 'Defer JavaScripts' settings please go to Stores -> Configuration -> Hryvinskyi Extensions -> Defer JavaScripts and expand the General Settings section.

Enabled deferred javascript: Enable or disable the extension from here.
Disable move attribute: Enter the attribute that will block the move of the script to the bottom.
Enabled minify body scripts: Enable script minification.

Features

  • Ability to skip javascripts with a special tag that can be set in the admin panel

  • Built-in skipping move Google tag manager (If you use a third-party module and can not add a special tag)

  • Exclude by controllers from defer parsing of JavaScript.

    Controller will be unaffected by defer js. Use like: [module][controller][action] (Example: cms_index_index)

  • Exclude by store paths from defer parsing of JavaScript.

    Paths will be unaffected by defer js. Use like: /women/tops-women/jackets-women.html

  • Exclude by url pattern from defer parsing of JavaScript.

    URL pattern can be a full action name or a request path. Wildcards are allowed. Like:

    *cell-phones*
    *cell-phones/nokia-2610-phone.html
    customer_account_*
    /customer/account/*
    *?mode=list
    
  • Minification of moved javascripts

  • Optimize text/x-magento-init scripts

  • Ability to extend the module with your validator

  • Increased rendering time improves the Google Page Speed score.

Add custom validator

To add your validator:

  1. Create Validator file app/code/Vendor/Module/Model/PassesValidator/Validators/YourValidator.php:

    <?php
    
    declare(strict_types=1);
    
    namespace Vendor\Module\Model\PassesValidator\Validators;
    
    use Hryvinskyi\DeferJs\Model\PassesValidator\ValidatorInterface;
    use Magento\Framework\App\Response\Http;
    
    /**
     * Class YourValidator
     */
    class YourValidator implements ValidatorInterface
    {
        /**
         * Validator function, handle javascript or not
         *
         * @param string $script
         * @param Http $http
         *
         * @return bool
         */
        public function validate(string $script, Http $http): bool
        {
            // Your code validate
        }
    }
  2. Create Dependency Injection file app/code/Vendor/Module/etc/frontend/di.xml:

    <?xml version="1.0"?>
    
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    
        <virtualType name="deferJsPassesValidators">
            <arguments>
                <argument name="entityTypes" xsi:type="array">
                    <item name="yourValidationName"
                          xsi:type="object">Vendor\Module\Model\PassesValidator\Validators\YourValidator</item>
                </argument>
            </arguments>
        </virtualType>
    </config>
  3. Run command:

    php bin/magento setup:di:compile
    

hryvinskyi/magento2-deferjs 适用场景与选型建议

hryvinskyi/magento2-deferjs 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 30.2k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2019 年 03 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 hryvinskyi/magento2-deferjs 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 hryvinskyi/magento2-deferjs 我们能提供哪些服务?
定制开发 / 二次开发

基于 hryvinskyi/magento2-deferjs 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 30.2k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 12
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 13
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-22