承接 blackbird/external-resources-loader 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

blackbird/external-resources-loader

最新稳定版本:1.0.6

Composer 安装命令:

composer require blackbird/external-resources-loader

包简介

Easily lazy load scripts and styles by url

README 文档

README

This tiny Magento 2 module will allow you to easily lazy load scripts and styles by url.

Installation

composer require blackbird/external-resources-loader
php bin/magento setup:upgrade

Usage

Load script :

blackbird.loadExternalResource('https://cdn.jsdelivr.net/npm/@splidejs/splide@4.1.4/dist/js/splide.min.js')
	.then(() => /* code which is executed after the lib has loaded */)

Load style :

blackbird.loadExternalResource('https://cdn.jsdelivr.net/npm/@splidejs/splide@4.1.4/dist/css/splide.min.css')
	.then(() => /* code which is executed after the style has loaded */)

Load multiple related scripts and styles :

Promise.all([
    blackbird.loadExternalResource('https://cdn.jsdelivr.net/npm/@splidejs/splide@4.1.4/dist/js/splide.min.js'),
    blackbird.loadExternalResource('https://cdn.jsdelivr.net/npm/@splidejs/splide@4.1.4/dist/css/splide.min.css')
]).then(() => /* code which is executed after the style and the lib has loaded */)

Troubleshooting

The loadExternalResource method will load a script or a style depending on the url extension. If the url doesn't end by .js or .css, you could lazy load resource using one of these 2 methods :

  • loadExternalScript : load resource from a url that provides javascript content
  • loadExternalStyle : load resource from a url that provides css content

For instance :

blackbird.loadExternalScript("<?= $block->getViewFileUrl('js/my-script') ?>")

统计信息

  • 总下载量: 16.57k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 1
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 2
  • Forks: 0
  • 开发语言: HTML

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-02