想要替换外部脚本HTTP请求(WordPress网站,不能使用插件)

发布于 2025-02-06 08:06:53 字数 307 浏览 2 评论 0原文

我有一个客户要求我解决他的问题。他会因其广告障碍物所阻挡外部JS脚本而遇到错误。主要是CDN站点。他不会让我们安装插件。

我开始考虑一个创意的解决方案,并编码了一些东西以在本地存储外部文件。(这是这样做的,不是询问存储文件)

我试图使用ob_start()替换Head Tag中的脚本链接,但它们似乎似乎以后加载,可能是插件的Ajax。我不知道。

另一个问题是,有些没有内联加载。 外部JavaScript文件正在其他地方加载。

有人知道我如何为客户解决这个问题吗? .htaccess是否会重定向将HTTP请求重定向到所有活动中并解决此问题?

I have a client who is asking for me to solve his issue. He gets errors for external js scripts getting blocked by his ad blocker. Mainly CDN sites. He wont let us install plugins.

I began to think of a creative solution, and coded up something to store external files locally.(This is done, not asking about storing files)

I was trying to use ob_start() to replace script links in the head tag, but they seem to be loading later, probably aJax, from plugins. I don't know.

Another issue is that some aren't getting loaded inline.
The external javascript files are getting loaded somewhere else.

Does anyone have any idea how I can solve this for my client?
would .htaccess redirects redirect the http requests across all activity and solve this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文