Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

能去掉奇大无比的"iconv-browser","@sinonjs/text-encoding"模块吗? #249

Closed
heroboy opened this issue Jun 1, 2020 · 6 comments
Closed

Comments

@heroboy
Copy link
Contributor

heroboy commented Jun 1, 2020

唯一用到的地方是在got的时候,encode url。但是下一页的地址都是从页面上获取的,基本上已经url encode好了的。

@machsix
Copy link
Owner

machsix commented Jun 1, 2020

不能,GM_xmlhttpRequest拿到的内容默认是utf8,要自己decode。fetch api之类的也一样。
1mb而已,其实还好。我留着也是因为GM_xmlhttpRequest的decode要自己设置

if (options.html && _.isString(options.encoding)) {
config.overrideMimeType = `text/html; charset=${options.encoding}`;
}

我想以后换成fetch API, 虽然也可以自己设置ContentType,但还是不太爽

@machsix machsix closed this as completed Jun 1, 2020
@machsix machsix reopened this Jun 1, 2020
@heroboy
Copy link
Contributor Author

heroboy commented Jun 1, 2020

我就是没有找到你任何decode的地方才问的。

@machsix
Copy link
Owner

machsix commented Jun 1, 2020

看上面的。

@heroboy
Copy link
Contributor Author

heroboy commented Jun 1, 2020

而且现代浏览器都能用TextDecoder了,不用自己decode了。你已经用了Array.includes了,已经抛弃老的浏览器了吧。
@include http*的脚本,尽量优化一下吧。
#238 的问题估计就是因为iframe太多了,载入脚本太慢了。

@heroboy
Copy link
Contributor Author

heroboy commented Jun 3, 2020

我测试一下在firefox+tampermonkey,关闭所有规则。
打开example.com,如果开启这个脚本的话,大约需要额外多执行100ms的js时间。
所以,像mdn这种iframe很多的网站,卡死也是可能的。

@heroboy
Copy link
Contributor Author

heroboy commented Jun 8, 2020

继续测试了一下,chrome+tampermonkey + example.com+禁用所有规则
页面载入完成之后,所有脚本执行时间:

  • 不开启这个脚本:50ms
  • 开启:200ms
  • 开启了移除这个模块之后的版本(脚本大小变成一半):170ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants