OP、
jQuery圧縮〜94 KB。 Zepto圧縮〜9.7 KB。
要するに、Zeptoを代わりに使用し、プラグインの最終行のjQueryへの参照をZeptoに変更すると、ちょうどがになります。 the docsによるとthis Fiddle
(function ($) {
$.fn.fitText = function (kompressor, options) {
// Setup options
var compressor = kompressor || 1,
settings = $.extend({
'minFontSize': Number.NEGATIVE_INFINITY,
'maxFontSize': Number.POSITIVE_INFINITY
}, options);
return this.each(function() {
// Store the object
var $this = $(this);
// Resizer() resizes items based on the object width divided by the compressor * 10
var resizer = function() {
$this.css('font-size', Math.max(Math.min($this.width()/(compressor * 10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize)));
};
// Call once to set.
resizer();
// Call on resize. Opera debounces their resize by default.
$(window).on('resize', resizer);
});
};
})(Zepto);
を参照してください:
Zeptoは主にjQueryの互換APIを備えたモダンなブラウザのミニマリストのJavaScriptライブラリです。
したがって、jQueryライブラリ全体を含めることなくjQueryプラグイン*を使用したい人の場合、Zeptoは妥当な回避策のようです。
* 100%jQueryカバレッジは設計目標ではありませんが、提供されるAPIはjQueryの対応するものと一致します。
希望するものがあります。
あなたはどのようなライブラリを使用している場合ではないjQueryのは、どんな場合?それをタグとして追加すると役立ちます。 –
[FitText.jsのソースコード](https://github.com/davatron5000/FitText.js/blob/master/jquery.fittext.js)の有効部分は、ほんの数行に過ぎません。 jQueryの依存関係を簡単に削除できます。 –
@KevinB現在のところありません。私はすべてを最小限に抑えています。私はとにかく(少なくとも今のところは)何も必要ありません。 – raf